1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. eukalyptus

Beiträge von eukalyptus

  • Rasterbator Clone - Erstellen von riesigen Postern

    • eukalyptus
    • 10. März 2009 um 01:11

    Inspiriert von Rasterbator, der Software zum erstellen von riesigen Postern http://homokaasu.org/rasterbator
    hab ich eine eigene Version geschrieben.
    Zum erstellen der Pdf verwende ich Haru Free PDF Library http://libharu.sourceforge.net (ist im Anhang dabei)

    Das Programm erstellt Halbtonbilder aus Bilddateien und teilt es auf mehrere Papierseiten auf.
    So kann man ein Foto auf z.b. 5x4 A4-Seiten ausdrucken und so ein Poster von etwa 1m² erstellen.
    Bei mehr Seiten etsprechend größer...

    Spoiler anzeigen
    [autoit]

    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GDIPlusConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $libhpdfdll = DllOpen(@ScriptDir & "\libhpdf.dll")
    If $libhpdfdll = -1 Then
    MsgBox(0, "ERROR", "Error loading libhpdf.dll")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $hImage, $iWidth, $iHeight, $iImageX, $iImageY, $iImageW, $iImageH, $iImageS, $CustomColor = 0xFF0000

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Autoit Rasterbator Clone by Eukalyptus", 400, 685)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUICtrlCreateButton("Load Source Image", 10, 10, 120, 20)
    GUICtrlSetOnEvent(-1, "_LoadImage")
    GUICtrlCreateLabel("", 10, 35, 380, 280)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("PaperSize:", 10, 333, 50, 20)
    Global $hPaperWidth = GUICtrlCreateInput("210", 70, 330, 40, 20, $ES_NUMBER)
    GUICtrlSetOnEvent(-1, "_ReDrawPreview")
    GUICtrlCreateLabel("x", 115, 333, 10, 20)
    Global $hPaperHeight = GUICtrlCreateInput("297", 130, 330, 40, 20, $ES_NUMBER)
    GUICtrlSetOnEvent(-1, "_ReDrawPreview")
    GUICtrlCreateLabel("mm", 175, 333, 20, 20)
    GUICtrlCreateCombo("", 210, 330, 180, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1, "_SetPaperSize")
    GUICtrlSetData(-1, "US LETTER PORTRAIT|US LETTER LANDSCAPE|US LEGAL PORTRAIT|US LEGAL LANDSCAPE|A3 PORTRAIT|A3 LANDSCAPE|A4 PORTRAIT|A4 LANDSCAPE|A5 PORTRAIT|A5 LANDSCAPE", "A4 PORTRAIT")
    Global $hPaperCount = GUICtrlCreateInput("5", 100, 365, 35, 20, $ES_NUMBER)
    GUICtrlSetOnEvent(-1, "_ReDrawPreview")
    GUICtrlCreateUpdown(-1)
    GUICtrlSetLimit(-1, 50, 1)
    GUICtrlCreateLabel("Sheets /", 145, 368, 50, 20)
    Global $hPaperCountDir = GUICtrlCreateCombo("", 200, 365, 60, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1, "_ReDrawPreview")
    GUICtrlSetData(-1, "Width|Height", "Width")
    GUICtrlCreateLabel("OutputSize: ", 10, 368, 60, 20)
    Global $hOutPutSize = GUICtrlCreateLabel("", 80, 393, 300, 20)
    GUICtrlCreateLabel("Optional Scale to Papersize:", 10, 428, 140, 20)
    Global $hScale = GUICtrlCreateSlider(160, 415, 150, 30, BitOR($TBS_LEFT, $TBS_AUTOTICKS))
    GUICtrlSetOnEvent(-1, "_SetScale")
    GUICtrlSetLimit(-1, 100, 10)
    GUICtrlSendMsg(-1, $TBM_SETTICFREQ, 10, 0)
    GUICtrlSetData(-1, 90)
    Global $hScaleInfo = GUICtrlCreateLabel("0.9", 330, 428, 50, 20)
    GUICtrlCreateLabel("DotSize:", 10, 463, 50, 20)
    Global $hDotSize = GUICtrlCreateInput("5", 100, 460, 35, 20, $ES_NUMBER)
    GUICtrlCreateUpdown(-1)
    GUICtrlSetLimit(-1, 50, 1)
    GUICtrlCreateLabel("mm", 140, 465, 50, 20)
    Global $hOutline = GUICtrlCreateCheckbox("Draw Outline", 200, 460, 100, 20)
    GUICtrlCreateLabel("DotColor:", 10, 498, 50, 20)
    GUIStartGroup()
    Global $hColorBlack = GUICtrlCreateRadio("Black", 100, 495, 50, 20)
    Global $hColorCustom = GUICtrlCreateRadio("Custom:", 100, 520, 60, 20)
    Global $hColorMulti = GUICtrlCreateRadio("Original Colors", 100, 545, 100, 20)
    GUICtrlSetState(-1, $GUI_CHECKED)
    Global $hCustomColor = GUICtrlCreateLabel("", 180, 520, 30, 20)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlCreateButton("Select Color", 230, 521, 80, 18)
    GUICtrlSetOnEvent(-1, "_SelectColor")
    GUICtrlCreateLabel("Output File:", 10, 583, 80, 20)
    Global $hOutputFile = GUICtrlCreateInput("", 100, 580, 290, 20)
    GUICtrlCreateButton("Rasterbate", 150, 615, 100, 30)
    GUICtrlSetOnEvent(-1, "_Rasterbate")
    Global $hProgress = GUICtrlCreateProgress(10, 655, 380, 20)
    GUISetState()
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
    GUIRegisterMsg($WM_ACTIVATE, "_WM_ACTIVATE")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _LoadImage()
    Local $sFilename, $sPdfFile, $Cnt = 0
    $sFilename = FileOpenDialog("Select Image...", @WorkingDir, "(*.bmp;*.jpg;*.tif)", 1)
    If @error Then Return
    $hImage = _GDIPlus_ImageLoadFromFile($sFilename)
    If @error Then Return
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    If 380 / $iWidth < 280 / $iHeight Then
    $iImageS = 380 / $iWidth
    Else
    $iImageS = 280 / $iHeight
    EndIf
    $iImageW = $iWidth * $iImageS
    $iImageH = $iHeight * $iImageS
    $iImageX = 200 - $iImageW / 2
    $iImageY = 175 - $iImageH / 2
    $sPdfFile = StringLeft($sFilename, StringInStr($sFilename, ".", 0, -1) - 1)
    If FileExists($sPdfFile & ".pdf") Then
    While 1
    $Cnt += 1
    If FileExists($sPdfFile & "_" & String($Cnt) & ".pdf") = 0 Then ExitLoop
    WEnd
    GUICtrlSetData($hOutputFile, $sPdfFile & "_" & String($Cnt) & ".pdf")
    Else
    GUICtrlSetData($hOutputFile, $sPdfFile & ".pdf")
    EndIf
    _ReDrawPreview()
    EndFunc ;==>_LoadImage

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetScale()
    GUICtrlSetData($hScaleInfo, GUICtrlRead($hScale) / 100)
    EndFunc ;==>_SetScale

    [/autoit] [autoit][/autoit] [autoit]

    Func _ReDrawPreview()
    _WM_Paint($hGui, 0, 0, 0)
    EndFunc ;==>_ReDrawPreview

    [/autoit] [autoit][/autoit] [autoit]

    Func _SelectColor()
    Local $Color
    $Color = _ChooseColor(2, $CustomColor, 2, $hGui)
    If @error Then Return
    $CustomColor = $Color
    If $CustomColor = 0xFFFFFF Then $CustomColor -= 0x000001
    GUICtrlSetBkColor($hCustomColor, $CustomColor)
    GUICtrlSetState($hColorCustom, $GUI_CHECKED)
    EndFunc ;==>_SelectColor

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_PAINT($hWnd, $Msg, $wParam, $lParam)
    If $hImage = 0 Then Return
    Local $iPageW = _mm2px(GUICtrlRead($hPaperWidth))
    Local $iPageH = _mm2px(GUICtrlRead($hPaperHeight))
    Local $iPageC = GUICtrlRead($hPaperCount)
    Local $iPageCX, $iPageCY
    _GDIPlus_GraphicsFillRect($hGraphics, 10, 35, 380, 280, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, $iImageX, $iImageY, $iImageW, $iImageH)
    Switch GUICtrlRead($hPaperCountDir)
    Case "Width"
    $iPageCX = $iWidth / $iPageC
    $iPageCY = $iWidth / $iPageC * $iPageH / $iPageW
    Case Else
    $iPageCY = $iHeight / $iPageC
    $iPageCX = $iHeight / $iPageC * $iPageW / $iPageH
    EndSwitch
    For $i = 0 To $iWidth Step Round($iPageCX)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iImageX + $i * $iImageS, $iImageY, $iImageX + $i * $iImageS, $iImageY + $iImageH)
    Next
    For $j = 0 To $iHeight Step Round($iPageCY)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iImageX, $iImageY + $j * $iImageS, $iImageX + $iImageW, $iImageY + $j * $iImageS)
    Next
    $iPageCX = Ceiling($iWidth / $iPageCX)
    $iPageCY = Ceiling($iHeight / $iPageCY)
    GUICtrlSetData($hOutPutSize, $iPageCX & " x " & $iPageCY & " = " & $iPageCX * $iPageCY & " sheets Size: " & _px2mm($iPageW * $iPageCX) & "mm x " & _px2mm($iPageH * $iPageCY) & "mm")
    EndFunc ;==>_WM_PAINT

    [/autoit] [autoit][/autoit] [autoit]

    Func _WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    Sleep(10)
    _ReDrawPreview()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_ACTIVATE

    [/autoit] [autoit][/autoit] [autoit]

    Func _SetPaperSize()
    Local $iX = GUICtrlRead($hPaperWidth), $iY = GUICtrlRead($hPaperHeight)
    Switch GUICtrlRead(@GUI_CtrlId)
    Case "US LETTER PORTRAIT"
    $iX = 216
    $iY = 279
    Case "US LETTER LANDSCAPE"
    $iX = 279
    $iY = 216
    Case "US LEGAL PORTRAIT"
    $iX = 216
    $iY = 355
    Case "US LEGAL LANDSCAPE"
    $iX = 355
    $iY = 216
    Case "A3 PORTRAIT"
    $iX = 297
    $iY = 420
    Case "A3 LANDSCAPE"
    $iX = 420
    $iY = 297
    Case "A4 PORTRAIT"
    $iX = 210
    $iY = 297
    Case "A4 LANDSCAPE"
    $iX = 297
    $iY = 210
    Case "A5 PORTRAIT"
    $iX = 148
    $iY = 210
    Case "A5 LANDSCAPE"
    $iX = 210
    $iY = 148
    EndSwitch
    GUICtrlSetData($hPaperWidth, $iX)
    GUICtrlSetData($hPaperHeight, $iY)
    _ReDrawPreview()
    EndFunc ;==>_SetPaperSize

    [/autoit] [autoit][/autoit] [autoit]

    Func _mm2px($imm)
    Return Round($imm * 72 / 25.4)
    EndFunc ;==>_mm2px

    [/autoit] [autoit][/autoit] [autoit]

    Func _px2mm($imm)
    Return Round($imm * 25.4 / 72, 1)
    EndFunc ;==>_px2mm

    [/autoit] [autoit][/autoit] [autoit]

    Func _Rasterbate()
    If $hImage = 0 Then Return
    Opt("GUIOnEventMode", 0)
    Local $iDotSize = GUICtrlRead($hDotSize)
    Local $iPageW = _mm2px(GUICtrlRead($hPaperWidth))
    Local $iPageH = _mm2px(GUICtrlRead($hPaperHeight))
    Local $iPageC = GUICtrlRead($hPaperCount)
    Local $iPageDir = 0
    If GUICtrlRead($hPaperCountDir) = "Height" Then $iPageDir = 1
    Local $Color = $CustomColor
    If GUICtrlRead($hColorBlack) = 1 Then $Color = 0x000000
    If GUICtrlRead($hColorMulti) = 1 Then $Color = 0xFFFFFF
    Local $bOutLine = False
    If GUICtrlRead($hOutline) = 1 Then $bOutLine = True
    Local $sPdfFile = GUICtrlRead($hOutputFile)
    Local $nScale = GUICtrlRead($hScale) / 100
    Local $hPdf = _HPDF_New()
    _Rasterize($hPdf, $iPageW, $iPageH, $hImage, $iWidth, $iHeight, $iPageC, $iPageDir, $nScale, $iDotSize, $Color, $bOutLine, $hProgress)
    _HPDF_SaveToFile($hPdf, $sPdfFile)
    _HPDF_Free($hPdf)
    GUICtrlSetData($hProgress, 0)
    Opt("GUIOnEventMode", 1)
    WinActivate($hGui)
    EndFunc ;==>_Rasterbate

    [/autoit] [autoit][/autoit] [autoit]

    Func _Rasterize($hPdf, $iPageW, $iPageH, $hBitmap, $iWidth, $iHeight, $iStep, $iDir, $nScale, $iRaster, $Color, $bOutLine = False, $hProgress = 0)
    $iRaster = $iRaster * 72 / 25.4
    Switch $iDir
    Case 0
    $iRaster = $iRaster / ($iStep * $iPageW / $iWidth)
    Case Else
    $iRaster = $iRaster / ($iStep * $iPageH / $iHeight)
    EndSwitch
    Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF24RGB)
    Local $Stride = DllStructGetData($BitmapData, "Stride")
    Local $Width = DllStructGetData($BitmapData, "Width")
    Local $Height = DllStructGetData($BitmapData, "Height")
    Local $PixelFormat = DllStructGetData($BitmapData, "PixelFormat")
    Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
    Local $pPixels = $Scan0
    Local $SquareX = Ceiling($Width / $iRaster), $SquareY = Ceiling($Height / $iRaster)
    Local $Row, $Col, $Cnt = 0, $Luma = 0, $Red, $Green, $Blue, $Size, $iRRaster = Ceiling($iRaster)
    Local $PixelData = DllStructCreate("ubyte lData[" & (Abs($Stride) * $Height - 1) & "]", $Scan0)
    Local $iStepW, $iStepH, $nPageScale = 1, $hPage, $iStepPageX, $iStepPageY
    Local $iPageCnt, $iPageDone = 0
    Switch $iDir
    Case 0
    $iStepW = Ceiling($SquareX / $iStep)
    $iStepH = Ceiling($SquareX / $iStep * $iPageH / $iPageW)
    $iStepPageX = Ceiling(($Width / $iRaster) / $iStepW)
    $iStepPageY = Ceiling(($Height / $iRaster) / $iStepH)
    Case 1
    $iStepH = Ceiling($SquareY / $iStep)
    $iStepW = Ceiling($SquareY / $iStep * $iPageW / $iPageH)
    $iStepPageX = Ceiling(($Width / $iRaster) / $iStepW)
    $iStepPageY = Ceiling(($Height / $iRaster) / $iStepH)
    EndSwitch
    If $iPageH / ($iStepH * $iRaster) < $iPageW / ($iStepW * $iRaster) Then
    $nPageScale = $iPageH / ($iStepH * $iRaster)
    Else
    $nPageScale = $iPageW / ($iStepW * $iRaster)
    EndIf
    $iPageCnt = $iStepPageX * $iStepPageY
    For $iStepY = 0 To $iStepPageY - 1
    For $iStepX = 0 To $iStepPageX - 1
    $hPage = _HPDF_AddPage($hPdf)
    _HPDF_Page_SetWidth($hPage, $iPageW)
    _HPDF_Page_SetHeight($hPage, $iPageH)
    _HPDF_Page_SetRotate($hPage, 180)
    _HPDF_Page_Concat($hPage, -1 * $nScale, 0, 0, 1 * $nScale, $iPageW - ($iPageW * (1 - $nScale) / 2), $iPageH * (1 - $nScale) / 2)
    _HPDF_Page_SetLineWidth($hPage, 0)
    For $iPosY = -1 To $iStepH
    GUICtrlSetData($hProgress, Round($iPageDone * 100 / $iPageCnt + ($iPosY * 100 / $iStepH) / $iPageCnt))
    If $iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $iRaster > $Height Then ExitLoop
    If $iStepY * $iStepH * $iRaster + $iPosY * $iRaster < 0 Then ContinueLoop
    For $iPosX = -1 To $iStepW
    If $iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $iRaster > $Width Then ExitLoop
    If $iStepX * $iStepW * $iRaster + $iPosX * $iRaster < 0 Then ContinueLoop
    $Luma = 0
    $Cnt = 0
    $Red = 0
    $Green = 0
    $Blue = 0
    For $Row = 0 To $iRRaster - 1
    For $Col = 0 To $iRRaster - 1
    Switch $Color
    Case 0xFFFFFF
    $Red += DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 3)
    $Green += DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 2)
    $Blue += DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 1)
    Case Else
    $Red = DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 3)
    $Green = DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 2)
    $Blue = DllStructGetData($PixelData, 1, Round($iStepY * $iStepH * $iRaster + $iPosY * $iRaster + $Row) * $Stride + Round($iStepX * $iStepW * $iRaster + $iPosX * $iRaster + $Col) * 3 + 1)
    $Luma += $Red * 0.3 + $Green * 0.59 + $Blue * 0.11
    EndSwitch
    $Cnt += 1
    Next
    Next
    Switch $Color
    Case 0xFFFFFF
    $Luma = $Red * 0.3 + $Green * 0.59 + $Blue * 0.11
    $Size = ((0xFF - ($Luma / $Cnt)) * $iRaster / 0xAF)
    _WritePdfData($hPage, ($iPosX * $iRaster + $iRaster / 2) * $nPageScale, ($iPosY * $iRaster + $iRaster / 2) * $nPageScale, $Size * $nPageScale, $Red / $Cnt / 0xFF, $Green / $Cnt / 0xFF, $Blue / $Cnt / 0xFF)
    Case Else
    $Size = ((0xFF - ($Luma / $Cnt)) * $iRaster / 0xAF)
    _WritePdfData($hPage, ($iPosX * $iRaster + $iRaster / 2) * $nPageScale, ($iPosY * $iRaster + $iRaster / 2) * $nPageScale, $Size * $nPageScale, BitAND(BitShift($Color, 16), 0xFF) / 0xFF, BitAND(BitShift($Color, 8), 0xFF) / 0xFF, BitAND($Color, 0xFF) / 0xFF)
    EndSwitch
    Next
    Next
    If $iStepY > 0 Or $iStepY < $iStepPageY - 1 Or $iStepX > 0 Or $iStepX < $iStepPageX - 1 Then _HPDF_Page_SetRGBFill($hPage, 1, 1, 1)
    If $iStepY > 0 Then _HPDF_Page_Rectangle($hPage, -$iRaster * 2 * $nPageScale, -$iRaster * 2 * $nPageScale, ($iStepW * $iRaster + $iRaster * 4) * $nPageScale, $iRaster * 2 * $nPageScale)
    If $iStepY < $iStepPageY - 1 Then _HPDF_Page_Rectangle($hPage, -$iRaster * 2 * $nPageScale, $iStepH * $iRaster * $nPageScale, ($iStepW * $iRaster + $iRaster * 4) * $nPageScale, $iRaster * 2 * $nPageScale)
    If $iStepX > 0 Then _HPDF_Page_Rectangle($hPage, -$iRaster * 2 * $nPageScale, -$iRaster * 2 * $nPageScale, $iRaster * 2 * $nPageScale, ($iStepH * $iRaster + $iRaster * 4) * $nPageScale)
    If $iStepX < $iStepPageX - 1 Then _HPDF_Page_Rectangle($hPage, $iStepW * $iRaster * $nPageScale, -$iRaster * 2 * $nPageScale, $iRaster * 2 * $nPageScale, ($iStepH * $iRaster + $iRaster * 4) * $nPageScale)
    If $iStepY > 0 Or $iStepY < $iStepPageY - 1 Or $iStepX > 0 Or $iStepX < $iStepPageX - 1 Then _HPDF_Page_Fill($hPage)
    If $bOutLine = True Then
    If $iStepX > 0 Then _DrawLineVertikal($hPage, 0, 0, $iStepH * $iRaster * $nPageScale)
    If $iStepX < $iStepPageX - 1 Then _DrawLineVertikal($hPage, $iStepW * $iRaster * $nPageScale, 0, $iStepH * $iRaster * $nPageScale)
    If $iStepY > 0 Then _DrawLineHorizontal($hPage, 0, 0, $iStepW * $iRaster * $nPageScale)
    If $iStepY < $iStepPageY - 1 Then _DrawLineHorizontal($hPage, 0, $iStepH * $iRaster * $nPageScale, $iStepW * $iRaster * $nPageScale)
    EndIf
    $iPageDone += 1
    Next
    Next
    GUICtrlSetData($hProgress, 100)
    _GDIPlus_BitmapUnlockBits($hBitmap, $BitmapData)
    EndFunc ;==>_Rasterize

    [/autoit] [autoit][/autoit] [autoit]

    Func _WritePdfData($hPage, $iX, $iY, $iD, $nR, $nG, $nB)
    _HPDF_Page_SetRGBFill($hPage, $nR, $nG, $nB)
    _HPDF_Page_Circle($hPage, $iX, $iY, $iD / 2)
    _HPDF_Page_Fill($hPage)
    EndFunc ;==>_WritePdfData

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawLineHorizontal($hPage, $iX, $iY, $iW)
    Local $j
    For $i = $iX To $iW Step 10
    $j = $i
    If $j > $iW - 10 Then $j = $iW - 10
    _HPDF_Page_SetRGBStroke($hPage, 1, 1, 0)
    _HPDF_Page_MoveTo($hPage, $j, $iY)
    _HPDF_Page_LineTo($hPage, $j + 5, $iY)
    _HPDF_Page_Stroke($hPage)
    _HPDF_Page_SetRGBStroke($hPage, 0, 0, 0)
    _HPDF_Page_MoveTo($hPage, $j + 5, $iY)
    _HPDF_Page_LineTo($hPage, $j + 10, $iY)
    _HPDF_Page_Stroke($hPage)
    Next
    EndFunc ;==>_DrawLineHorizontal

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawLineVertikal($hPage, $iX, $iY, $iW)
    Local $j
    For $i = $iY To $iW Step 10
    $j = $i
    If $j > $iW - 10 Then $j = $iW - 10
    _HPDF_Page_SetRGBStroke($hPage, 1, 1, 0)
    _HPDF_Page_MoveTo($hPage, $iX, $j)
    _HPDF_Page_LineTo($hPage, $iX, $j + 5)
    _HPDF_Page_Stroke($hPage)
    _HPDF_Page_SetRGBStroke($hPage, 0, 0, 0)
    _HPDF_Page_MoveTo($hPage, $iX, $j + 5)
    _HPDF_Page_LineTo($hPage, $iX, $j + 10)
    _HPDF_Page_Stroke($hPage)
    Next
    EndFunc ;==>_DrawLineVertikal

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetRotate($hPage, $iAngle)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetRotate", "ptr", $hPage, "uint", $iAngle)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetRotate

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_Concat($hPage, $a, $b, $c, $d, $X, $Y)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_Concat", "ptr", $hPage, "float", $a, "float", $b, "float", $c, "float", $d, "float", $X, "float", $Y)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_Concat

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_SetPageMode($hPage, $iMode)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_SetPageMode", "ptr", $hPage, "dword", $iMode)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_SetPageMode

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_Stroke($hPage)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_Stroke", "ptr", $hPage)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_Stroke

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetRGBStroke($hPage, $nRed, $nGreen, $nBlue)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetRGBStroke", "ptr", $hPage, "float", $nRed, "float", $nGreen, "float", $nBlue)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetRGBStroke

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_Fill($hPage)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_Fill", "ptr", $hPage)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_Fill

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetRGBFill($hPage, $nRed, $nGreen, $nBlue)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetRGBFill", "ptr", $hPage, "float", $nRed, "float", $nGreen, "float", $nBlue)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetRGBFill

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_MoveTo($hPage, $nX, $nY)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_MoveTo", "ptr", $hPage, "float", $nX, "float", $nY)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_MoveTo

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_LineTo($hPage, $nX, $nY)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_LineTo", "ptr", $hPage, "float", $nX, "float", $nY)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_LineTo

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetLineWidth($hPage, $nW)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetLineWidth", "ptr", $hPage, "float", $nW)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetLineWidth

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_Rectangle($hPage, $nX, $nY, $nW, $nH)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_Rectangle", "ptr", $hPage, "float", $nX, "float", $nY, "float", $nW, "float", $nH)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_Rectangle

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_Circle($hPage, $nX, $nY, $nRadius)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_Circle", "ptr", $hPage, "float", $nX, "float", $nY, "float", $nRadius)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_Circle

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetWidth($hPage, $nWidth)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetWidth", "ptr", $hPage, "float", $nWidth)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetWidth

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetHeight($hPage, $nHeight)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetHeight", "ptr", $hPage, "float", $nHeight)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetHeight

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Page_SetSize($hPage, $iSize, $iDirection)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Page_SetSize", "ptr", $hPage, "dword", $iSize, "dword", $iDirection)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Page_SetSize

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_Free($hPdf)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_Free", "ptr", $hPdf)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_Free

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_AddPage($hPdf)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_AddPage", "ptr", $hPdf)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_AddPage

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_SaveToFile($hPdf, $sFilename)
    Local $aReturn
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_SaveToFile", "ptr", $hPdf, "str", $sFilename)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_SaveToFile

    [/autoit] [autoit][/autoit] [autoit]

    Func _HPDF_New()
    Local $aReturn
    Local $error_handler = DllStructCreate("ulong error_no;ulong detail_no;ptr* user_data")
    $aReturn = DllCall($libhpdfdll, "int", "HPDF_New", "ptr", $error_handler, "ptr", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aReturn[0]
    EndFunc ;==>_HPDF_New

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Viel Vergnügen!
    lgE

  • pixelgröße eines bildes verändern...

    • eukalyptus
    • 7. März 2009 um 13:26

    Hast du Autoit Version 3.3.0.0 ?

  • pixelgröße eines bildes verändern...

    • eukalyptus
    • 7. März 2009 um 11:55

    Hi nochmals

    Da ich für mein aktuelles Projekt eine Funktion brauche, welche die Dpiauflösung verändern kann, hab ich nun diese Funktion geschrieben:

    [autoit]

    Func _GDIPlus_BitmapSetResolution($hBmp, $iDpiX, $iDpiY)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipBitmapSetResolution", "ptr", $hBmp, "float", $iDpiX, "float", $iDpiY)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0])
    EndFunc ;==>_GDIPlus_BitmapSetResolution

    [/autoit]


    d.h. Mein Beispiel von oben soll nun so aussehen:

    [autoit]

    #include <GdiPlus.au3>

    [/autoit][autoit][/autoit][autoit]

    Global $sFile = FileOpenDialog("Wähle Bild aus...", @WorkingDir, "(*.bmp)(*.jpg)(*.tif)", 1)
    If @error Then Exit
    Global $sExt = StringRight($sFile, 3)
    Global $iWidth = 400
    Global $iHeight = 300

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_Startup()
    Global $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Global $iOrigDpiX = _GDIPlus_ImageGetHorizontalResolution($hImage)
    Global $iOrigDpiY = _GDIPlus_ImageGetVerticalResolution($hImage)

    [/autoit][autoit][/autoit][autoit]

    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_BitmapSetResolution($hBitmap, $iOrigDpiX, $iOrigDpiY)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)
    _GDIPlus_ImageSaveToFile($hBitmap, StringTrimRight($sFile, 4) & "_resized." & $sExt)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    [/autoit][autoit][/autoit][autoit]

    Func _GDIPlus_BitmapSetResolution($hBmp, $iDpiX, $iDpiY)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipBitmapSetResolution", "ptr", $hBmp, "float", $iDpiX, "float", $iDpiY)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0])
    EndFunc ;==>_GDIPlus_BitmapSetResolution

    [/autoit]

    lgE

  • pixelgröße eines bildes verändern...

    • eukalyptus
    • 7. März 2009 um 11:36

    Hi

    Ja, es geht:

    [autoit]

    #include <GdiPlus.au3>

    [/autoit][autoit][/autoit][autoit]

    Global $sFile = FileOpenDialog("Wähle Bild aus...", @WorkingDir, "(*.bmp)(*.jpg)(*.tif)", 1)
    Global $sExt = StringRight($sFile, 3)
    Global $iWidth = 400
    Global $iHeight = 300

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_Startup()
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    _GDIPlus_GraphicsDispose($hGraphics)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)
    _GDIPlus_ImageSaveToFile($hBitmap, StringTrimRight($sFile, 4) & "_resized." & $sExt)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    [/autoit]

    Allerdings wird das Ziel aus dem Desktop erstellt und deshalb hat man dann 96 Dpi Auflösung, egal wieviel Dpi das Original hatte...
    Ist aber nur relevant, wenn man mit mm statt px arbeiten will...

    lgE

  • keine reaktion auf Button in GUI

    • eukalyptus
    • 3. März 2009 um 11:23

    Hi

    Das Problem ist, daß das Label sich mit den Buttons überschneidet und so die Buttons nicht anklickbar sind!
    Du mußt das Label deaktivieren:

    [autoit]

    GUICtrlSetState(-1,$GUI_DISABLE)

    [/autoit]


    (nach Guictrlcreatelabel)

    Oder die Größe anpassen...

    lgE

  • keine reaktion auf Button in GUI

    • eukalyptus
    • 3. März 2009 um 09:39

    Hi

    [autoit]

    GUIctrlsetOnEvent($Button[$i],"copy1")

    [/autoit]


    gehört mit in die Schleife, wo du die Buttons erstellst...

    lgE

  • Geburtstag von eukalyptus

    • eukalyptus
    • 2. März 2009 um 22:18

    Danke, Danke für die Glückwünsche!

    Freu mich total, zu der Autoit.de Gemeinde zu gehören! :thumbup:

  • Herausfinden, ob Script/.exe von bestimmtem Script/exe ausgeführt worden ist

    • eukalyptus
    • 2. März 2009 um 22:11

    Hi

    Einfachste Mögichkeit:
    Du übergibst einen Commandlineparameter:

    Script1:

    [autoit]

    Run(@ScriptDir & "\Script2.exe OK")

    [/autoit]


    Script2:

    [autoit]

    If $CmdLine[0] <> 1 Then Exit
    If $CmdLine[1] <> "OK" Then Exit

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0, "Hurra", "Script 2 wurde erfolgreich gestartet")

    [/autoit]


    2 Möglichkeit:
    Du checkst, ob die PID ein Childprocess vom PID (Fenstertitel) ist:
    Script1:

    [autoit]

    GUICreate("Script 1")
    GUISetState()
    Runwait(@ScriptDir & "\Script2.exe")

    [/autoit]


    Script2:

    [autoit]

    $iPidParent = WinGetProcess("Script 1")
    $aChildProcesses = _ProcessGetChildren($iPidParent)
    If @error Then Exit
    $bRun = False
    For $i = 1 To $aChildProcesses[0][0]
    If $aChildProcesses[$i][0] = @AutoItPID Then $bRun = True
    Next
    If $bRun = False Then Exit

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0, "Hurra", "Script 2 wurde erfolgreich gestartet")

    [/autoit][autoit][/autoit][autoit]

    Func _ProcessGetChildren($i_pid) ; First level children processes only
    Local Const $TH32CS_SNAPPROCESS = 0x00000002
    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)
    Local $tagPROCESSENTRY32 = _
    DllStructCreate _
    ( _
    "dword dwsize;" & _
    "dword cntUsage;" & _
    "dword th32ProcessID;" & _
    "uint th32DefaultHeapID;" & _
    "dword th32ModuleID;" & _
    "dword cntThreads;" & _
    "dword th32ParentProcessID;" & _
    "long pcPriClassBase;" & _
    "dword dwFlags;" & _
    "char szExeFile[260]" _
    )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)
    Local $a_pnext, $a_children[11][2] = [[10]], $i_child_pid, $i_parent_pid, $i_add = 0
    $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
    If $i_child_pid <> $i_pid Then
    $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    If $i_parent_pid = $i_pid Then
    $i_add += 1
    $a_children[$i_add][0] = $i_child_pid
    $a_children[$i_add][1] = DllStructGetData($tagPROCESSENTRY32, "szExeFile")
    EndIf
    EndIf
    While 1
    $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop
    $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
    If $i_child_pid <> $i_pid Then
    $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    If $i_parent_pid = $i_pid Then
    If $i_add = $a_children[0][0] Then
    ReDim $a_children[$a_children[0][0] + 11][2]
    $a_children[0][0] = $a_children[0][0] + 10
    EndIf
    $i_add += 1
    $a_children[$i_add][0] = $i_child_pid
    $a_children[$i_add][1] = DllStructGetData($tagPROCESSENTRY32, "szExeFile")
    EndIf
    EndIf
    WEnd
    If $i_add <> 0 Then
    ReDim $a_children[$i_add + 1][2]
    $a_children[0][0] = $i_add
    EndIf
    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    If $i_add Then Return $a_children
    Return SetError(3, 0, 0)
    EndFunc ;==>_ProcessGetChildren

    [/autoit]

    lgE

  • µit - Februar

    • eukalyptus
    • 28. Februar 2009 um 10:25

    Hi

    muß auch sagen, daß es etwas sinnlos ist... hab aber trotzdem eine Formelauswertung geschrieben.

    Das treibende Element war, daß ich mich endlich mal mit StringRegExp auseinandersetzen wollte
    und es hat geholfen!
    Ich glaub jetzt hab ich die regular expressions endlich durchschaut :thumbup:

    Ich denke mal, ich brauche es nicht Passworten ;)
    (Außer es kommt noch ein weiterer Teilnehmer...)

    Spoiler anzeigen
    [autoit]

    Global $aFormel[5]
    $aFormel[0] = "sqrt(10^5)*log(25)"
    $aFormel[1] = "(2* sin(20)^2)/(-sqrt(120)-cos(20))"
    $aFormel[2] = "sin(20)"
    $aFormel[3] = "sin 20"
    $aFormel[4] = "10 mod 3"

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 4
    MsgBox(0, $i, 'Formel: "' & $aFormel[$i] & '"' & @LF & @LF & "Mein Ergebnis: " & _evaluate($aFormel[$i]) & @LF & "Autoit Ergebnis: " & Execute($aFormel[$i]))
    Next

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, "Ergebnis", _evaluate(InputBox("Formelauswertung", "Bitte Formel eingeben:")))

    [/autoit] [autoit][/autoit] [autoit]

    Func _evaluate($sForm, $bStart = True)
    If $bStart Then
    Local $KL, $KR
    $sForm = StringStripWS($sForm, 8)
    $KL = StringRegExp($sForm, "\(", 3)
    $KR = StringRegExp($sForm, "\)", 3)
    If UBound($KL) <> UBound($KR) Then Return SetError(1, 0, "Klammer Fehler")
    EndIf
    Local $aFunc[9] = ["sin", "cos", "tan", "asin", "acos", "atan", "sqrt", "exp", "log"]
    Local $aCalc[6] = ["[\^]", "\*", "\/", "mod", "\-", "\+"]
    Local $aRet, $iRes
    While StringRegExp($sForm, "\([^\(]*?\)")
    $aRet = StringRegExp($sForm, "\([^\(]*?\)", 1)
    If Not @error Then
    $iRes = _evaluate(StringTrimRight(StringTrimLeft($aRet[0], 1), 1), False)
    $sForm = StringRegExpReplace($sForm, "\([^\(]*?\)", $iRes, 1)
    EndIf
    WEnd
    For $i In $aFunc
    While StringRegExp($sForm, "(?i)" & $i & "[0-9.]*")
    $aRet = StringRegExp($sForm, "(?i)" & $i & "[0-9.]*", 3)
    If Not @error Then
    $iRes = _Calc($i, StringTrimLeft($aRet[0], StringLen($i)))
    $sForm = StringRegExpReplace($sForm, "(?i)" & $i & "[0-9.]*", $iRes, 1)
    EndIf
    WEnd
    Next
    While StringRegExp($sForm, "[\^\+\-\*\/]|mod")
    For $i In $aCalc
    $aRet = StringRegExp($sForm, "\-?[0-9.]*" & $i & "\-?[0-9.]*", 3)
    If Not @error And $aRet[0] <> $sForm Then
    $iRes = _evaluate($aRet[0])
    $sForm = StringRegExpReplace($sForm, "\-?[0-9.]*" & $i & "\-?[0-9.]*", $iRes, 1)
    ElseIf Not @error And $aRet[0] = $sForm Then
    Return _Calc($i, $sForm)
    EndIf
    Next
    WEnd
    Return $sForm
    EndFunc ;==>_evaluate

    [/autoit] [autoit][/autoit] [autoit]

    Func _Calc($sOp, $sExpr)
    Local $aExpr
    Switch String($sOp)
    Case 'sin'
    Return Sin($sExpr)
    Case 'cos'
    Return Cos($sExpr)
    Case 'tan'
    Return Tan($sExpr)
    Case 'asin'
    Return ASin($sExpr)
    Case 'acos'
    Return ACos($sExpr)
    Case 'atan'
    Return ATan($sExpr)
    Case 'sqrt'
    Return Sqrt($sExpr)
    Case 'exp'
    Return Exp($sExpr)
    Case 'log'
    Return Log($sExpr)
    Case '[\^]'
    $aExpr = StringSplit($sExpr, "^")
    Return $aExpr[1] ^ $aExpr[2]
    Case '\+'
    $aExpr = StringSplit($sExpr, "+")
    Return $aExpr[1] + $aExpr[2]
    Case '\-'
    Local $aTmp[2] = [0, 0]
    $aExpr = StringRegExp($sExpr, "\-?[0-9.]+\-?", 3)
    If UBound($aExpr) < 2 Then $aExpr = $aTmp
    $aTmp = StringRegExp($sExpr, "\-?[0-9.]+", 1)
    If UBound($aTmp) >= 1 Then $aExpr[0] = $aTmp[0]
    Return $aExpr[0] - $aExpr[1]
    Case '\*'
    $aExpr = StringSplit($sExpr, "*")
    Return $aExpr[1] * $aExpr[2]
    Case '\/'
    $aExpr = StringSplit($sExpr, "/")
    Return $aExpr[1] / $aExpr[2]
    Case 'mod'
    $aExpr = StringSplit($sExpr, "mod")
    Return Mod($aExpr[1], $aExpr[$aExpr[0]])
    Case Else
    Return $sExpr
    EndSwitch
    EndFunc ;==>_Calc

    [/autoit]

    lgE

  • SVG Vektor Grafik - Wer kann mir weiterhelfen?

    • eukalyptus
    • 26. Februar 2009 um 16:54

    Hi

    Danke ich habs geschafft!
    Die ersten beiden Koordinaten sind X/Y vom Startpunkt.
    Ab dem "c" kommen die Koordinaten der 4 Viertelkreise im Dreierpack.
    Jeweils die letzten sind dann X/Y vom Virtelkreisende...

    Somit kann ich nun Mittelpunkt und Radius ausrechnen.

  • SVG Vektor Grafik - Wer kann mir weiterhelfen?

    • eukalyptus
    • 25. Februar 2009 um 18:45

    Hi

    Folgendes SVG beinhaltet einen kreisförmigen Pfad:

    XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <!-- Creator: CorelDRAW -->
    <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="210mm" height="297mm" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
    viewBox="0 0 210 297"
     xmlns:xlink="http://www.w3.org/1999/xlink">
     <defs>
      <style type="text/css">
       <![CDATA[
    .fil0 {fill:black;fill-rule:nonzero}
       ]]>
      </style>
     </defs>
     <g id="Ebene_x0020_1">
      <metadata id="CorelCorpID_0Corel-Layer"/>
      <path class="fil0" d="M166.693 128.177c0,-35.4412 -28.735,-64.1762 -64.1762,-64.1762 -35.5434,0 -64.2784,28.735 -64.2784,64.1762 0,35.5434 28.735,64.2784 64.2784,64.2784 35.4412,0 64.1762,-28.735 64.1762,-64.2784z"/>
     </g>
    </svg>
    Alles anzeigen

    Wie kann ich den Pfad in einen richtigen Kreis (X,Y,Radius) umwandeln?

    Code
    <circle cx="1234" cy="1234" r="1234">

    bzw. für was stehen die einzelnen Koordinaten im Pfad?
    Das erste ist natürlich der Anfangspunkt, aber wie gehts dann weiter?

    Code
    <path class="fil0" d="M166.693 128.177c0,-35.4412 -28.735,-64.1762 -64.1762,-64.1762 -35.5434,0 -64.2784,28.735 -64.2784,64.1762 0,35.5434 28.735,64.2784 64.2784,64.2784 35.4412,0 64.1762,-28.735 64.1762,-64.2784z"/>

    Ich hoffe, es kann mir jemand helfen!

    thx
    E

  • Schatten erstellen

    • eukalyptus
    • 24. Februar 2009 um 14:55

    Guckst du hier:
    http://www.autoitscript.com/forum/index.php?showtopic=47651

    lgE

  • GuiCtrlCreatePic in Tab

    • eukalyptus
    • 24. Februar 2009 um 01:52

    Hi

    Du mußt nach GuiCtrlCreatePic noch folgendes einfügen:

    [autoit]

    GuiCtrlCreateTabItem("")

    [/autoit]

    lgE

  • Autoit Mp3 DJ

    • eukalyptus
    • 24. Februar 2009 um 01:17

    Hallo

    Ein DJ-Programm im Denon DN2000 Look
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Hatte ursprünglich 2 Scripte, eins zum Waveformzeichnen und das andere zum regeln der Geschwindigkeit.
    Hab die beiden kombiniert und langsam ist das Programm dann gewachsen.
    Leider hab ich zuviel herumprobiert, sodaß ich letztendlich den Überblick verloren hab...

    d.h.: Es sind noch viele Bugs drinnen!
    Will es euch aber dennoch mal zeigen...

    Bei 2 Audiointerfaces kann man getrennt Abspielen und Vorhören.
    Mit den Variablen $iMainDevice und $iMonDevice kann man das einstellen...

    http://rapidshare.com/files/201769180/AMD.rar


    Viel Spaß :D

    ps.: Die CloneStr.dll (Pascal-Source ist dabei) hab ich mit Dev-Pascal compiliert.

  • Wie eine Transparente GUI erstellen?

    • eukalyptus
    • 23. Februar 2009 um 19:42

    Das $WS_POPUP kommt einen Beistrich vorher...

    $WS... sind normale styles
    $WS_EX... sind extended styles

    lgE

  • Wie eine Transparente GUI erstellen?

    • eukalyptus
    • 23. Februar 2009 um 19:17

    Sowas?

    Wenn du $WS_POPUP verwendest, ist nur mehr der Test da...

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("", 300, 100, -1, -1, -1, $WS_EX_LAYERED)
    GUISetBkColor(0xABCDEF)
    $hLabel = GUICtrlCreateLabel("Test", 5, 5, 290, 90, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetFont($hLabel, 60)
    GUICtrlSetColor($hLabel, 0x00FF00)
    GUICtrlSetBkColor($hLabel, 0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While GUIGetMsg() <> -3
    Sleep(5)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
    $i_transcolor = Hex(String($i_transcolor), 6)
    $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
    Case @error
    Return SetError(@error, 0, 0)
    Case $Ret[0] = 0
    Return SetError(4, _WinAPI_GetLastError(), 0)
    Case Else
    Return 1
    EndSelect
    EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

    [/autoit]

    lgE

  • Problem bei GuiCtrlSetData und Groß/Kleinschreibung des 2. Parameters

    • eukalyptus
    • 23. Februar 2009 um 14:50
    Code
    If the "data" corresponds to an already existing entry it is set as the  default.
    If the "data" starts with GUIDataSeparatorChar or is an empty string  "" the previous list is destroyed.

    In deinem Beispiel wird der Eintrag "Test" mit "test" als default gesetzt - scheint nicht casesensitive zu sein.
    wenn du willst, daß der alte EIntrag überschrieben wird, dann:

    [autoit]

    GuiCtrlSetData(-1, "|" & $var)

    [/autoit]

    zum hinzufügen:

    [autoit]

    _GUICtrlListBox_AddString

    [/autoit]

    lgE

  • Select/If

    • eukalyptus
    • 22. Februar 2009 um 20:57

    Hi

    ist eigentlich Geschmackssache, was du verwendest.

    Select...Case...EndSelect ist etwas schneller als If...Then...Endif
    Außer man verzichtet auf Endif

    [autoit]

    If $Var > 10 Then MsgBox(0,"","")

    [/autoit]

    , dann ist IF schneller.

    Ich persönlich verwende nur IF, da ich dann den Code leichter lesen kann...
    Und eben Switch, mit vielen Vergleichen bei nur einer Auswertung.

    lgE

  • _GDIPlus_GraphicsDrawString in Farbe

    • eukalyptus
    • 22. Februar 2009 um 20:34

    hi

    [autoit]

    #include <GdiPlus.au3>

    [/autoit][autoit][/autoit][autoit]

    $hGui = GUICreate("Test")
    GUISetState()

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    _GDIPlus_GraphicsDrawStringColor($hGraphics, "TestString", 10, 10, "Arial", 20, 0, 0xFFFF6600)

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0, "", "Fertig")
    _GDIPlus_Shutdown()

    [/autoit][autoit][/autoit][autoit]

    Func _GDIPlus_GraphicsDrawStringColor($hGraphics, $sString, $nX, $nY, $sFont = "Arial", $nSize = 10, $iFormat = 0, $iBrush = 0xFF000000)
    Local $hBrush, $iError, $hFamily, $hFont, $hFormat, $aInfo, $tLayout, $bResult

    [/autoit][autoit][/autoit][autoit]

    $hBrush = _GDIPlus_BrushCreateSolid($iBrush)
    $hFormat = _GDIPlus_StringFormatCreate($iFormat)
    $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    $hFont = _GDIPlus_FontCreate($hFamily, $nSize)
    $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
    $bResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    $iError = @error
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    Return SetError($iError, 0, $bResult)
    EndFunc ;==>_GDIPlus_GraphicsDrawStringColor

    [/autoit]

    Die Funktion _GDIPlus_GraphicsDrawStringColor hab ich aus der GdiPlus.au3 rauskopiert und erweitert...

    Vielleicht sollte man das mal anregen, daß ein Farbparameter gleich in die original Funktion integriert wird!

    lgE

  • _GDIPlus_GraphicsDrawString in Farbe

    • eukalyptus
    • 22. Februar 2009 um 20:02

    Schau dir die Funktion in der GDIPlus.au3 an und du wirst feststellen, daß dort mit:

    [autoit]

    $hBrush = _GDIPlus_BrushCreateSolid()

    [/autoit]


    einfach ein schwarzer Brush erstellt wird...

    Also Funktion in dein Script kopieren, umbenennen und einen Farbwert einfügen z.b.:

    [autoit]

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE9922)

    [/autoit]

    Warum man den Farbwert nicht gleich als Parameter mitgeben kann ist mir ein Rätsel...

    lgE

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™