Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#26

Re: PNG-Graphik über "System" laden ... ?

  Alt 24. Okt 2008, 15:55
Hier ein Sample
mußt selbst übersetzen dürfte aber kein problem sein.

Delphi-Quellcode:
Private Function MakeTrans(pngPath As String) As Boolean
Dim tempBI As BITMAPINFO
Dim lngHeight As Long
Dim lngWidth As Long
Dim curWinLong As Long
Dim img As Long
Dim graphics As Long
Dim winSize As Size
Dim srcPoint As POINTAPI
    With tempBI.bmiHeader
        .biSize = Len(tempBI.bmiHeader)
        .biBitCount = 32
        .biHeight = ScaleHeight
        .biWidth = ScaleWidth
        .biPlanes = 1
        .biSizeImage = .biWidth * .biHeight * (.biBitCount / 8)
    End With
        mDC = CreateCompatibleDC(hdc)
        mainBitmap = CreateDIBSection(mDC, tempBI, DIB_RGB_COLORS, ByVal 0, 0, 0)
        oldBitmap = SelectObject(mDC, mainBitmap)
        Call GdipCreateFromHDC(mDC, graphics)
        Call GdipLoadImageFromFile(StrConv(pngPath, vbUnicode), img)
        Call GdipGetImageHeight(img, lngHeight)
        Call GdipGetImageWidth(img, lngWidth)
        Call GdipDrawImageRect(graphics, img, 0, 0, lngWidth, lngHeight)
        curWinLong = GetWindowLong(hwnd, GWL_EXSTYLE)
        SetWindowLong hwnd, GWL_EXSTYLE, curWinLong Or WS_EX_LAYERED
        SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
        srcPoint.x = 0
        srcPoint.y = 0
        winSize.cx = lngWidth
        winSize.cy = lngHeight
    With blendFunc32bpp
        .AlphaFormat = AC_SRC_ALPHA
        .BlendFlags = 0
        .BlendOp = AC_SRC_OVER
        .SourceConstantAlpha = 255
    End With
Call GdipDisposeImage(img)
Call GdipDeleteGraphics(graphics)
Call UpdateLayeredWindow(hwnd, hdc, ByVal 0&, winSize, mDC, srcPoint, 0, blendFunc32bpp, ULW_ALPHA)
End Function
Alle Call's entfernen ..

gruss Emil
  Mit Zitat antworten Zitat