PNG images loaded with GDIBmp should display transparently by default when using Graphics:DrawImage(). Based on the FiveWin codebase, here's what you need to check:
Correct Usage Pattern (from samples/graphics/gdiplus3.prg:58-69):
local hdc := oWnd:getdc()
local oGraphics := Graphics():New( oWnd:hDC )
local oImage := GDIBmp():new("C:\fwh\bitmaps\pngs\image2.png" )
oGraphics:DrawImage( oImage, 60, 60 )
oGraphics:destroy()
oWnd:releasedc()
Common Issues:
Check your DrawImage call - Your code shows oGraphics:DrawImage( ::aImages, 1, aPos ) which looks incorrect. DrawImage expects:
First parameter: a GDIBmp object (not an array)
Second parameter: nTop (numeric)
Third parameter: nLeft (numeric)
Optional: nWidth, nHeight
Should be: oGraphics:DrawImage( ::aImages[1], nTop, nLeft )
Verify PNG has alpha channel - After loading, check:
oImage1 := GDIBmp():new(, ::aNameImages[1] )
IF !oImage1:IsAlphaChannel()
// PNG doesn't have alpha, or loaded incorrectly
oImage1:Set32Bits(.T.)
oImage1:Conver24to32Alpha(.T.) // Convert using top-left pixel as transparent color
ENDIF
Resource vs File loading - If loading from resources (second parameter), ensure PNG is embedded as RCDATA (type 10), not BITMAP (type 2). For file loading, use first parameter:
oImage1 := GDIBmp():new("c:\path\image.png") // File
// OR
oImage1 := GDIBmp():new(, "MYPNG") // Resource (must be RCDATA type 10)
Ensure high quality rendering:
oGraphics := Graphics():New( hDC )
oGraphics:SetHighQuality() // Ensures proper alpha blending
The transparency should work automatically with GDI+ if the PNG has an alpha channel and you're using the correct syntax. Check your DrawImage parameters first.