Page 1 of 1

Printing BITMAP with transparent background

Posted: Wed Feb 28, 2024 4:30 am
by skiman
Hi,

When printing a bitmap with transparent background sometimes this will be just a black rectangle.

See also:
https://ilx.alaska-software.com/index.p ... areas.133/

This can be implemented in Express in _dcprc.prg.

Add the function at the bottom:

Code: Select all

FUNCTION GetPrintBitmap( oBmp )
 LOCAL oRet
 LOCAL oPS

   IF .NOT. oBmp:hasAlphaChannel .AND. oBmp:transparentClr == GRA_CLR_INVALID
      RETURN oBmp
   ENDIF

   oRet := XbpBitmap():new():create()
   oRet:make( obmp:xSize, oBmp:ySize )
 
   oPS := XbpPresSpace():new():create()
   oRet:presSpace( oPS )

   GraSetColor( oPS, GRA_CLR_WHITE, GRA_CLR_WHITE )
   GraBox( oPS, {0,0}, {obmp:xSize-1,oBmp:ySize-1}, GRA_FILL )
   oBmp:draw( oPS, {0,0,oBmp:xSize-1,oBmp:ySize-1} )
   oPS:destroy()
RETURN oRet
On about line 1348 modify the code to:

Code: Select all

  BEGIN SEQUENCE
  oBitmap := GetPrintBitmap( oBitmap )     // ADD THIS LINE
  oBitmap:draw( ::oPS, aTarget, aSource, , nRasterOp )
  Sleep(1)
  END SEQUENCE

Re: Printing BITMAP with transparent background

Posted: Mon Apr 08, 2024 12:14 pm
by rdonnay
Chris -

Thanks for that contribution. I will add it to the next build.