Alaska Software Inc. - GraBitBlt() Question
Username: Password:
AuthorTopic: GraBitBlt() Question
Carlos a Beling GraBitBlt() Question
on Sat, 07 Apr 2018 17:00:31 -0300
Good afternoon.
I was playing with the GraBitBlt() function and I thing that it is not 
possible rendering a XbpPresSpace() in another one without it is not 
linked to a XbpBitmap() for example.
Is it right?
Please take a look in the attached Test program and if it is possible to 
do this, what is going wrong?

Fraternally
Beling


Test.zip
Jim LeeRe: GraBitBlt() Question
on Sat, 07 Apr 2018 22:29:52 +0200
you have a o:lockPS() and a XbpPresSpace() which is different.
you try to draw into o:DrawingArea which is not recommend. use a XbpStatic 
as Parent
Carlos a Beling Re: GraBitBlt() Question
on Tue, 10 Apr 2018 10:22:36 -0300
Hello Jim:
good morning.
Many thanks.
I finally understood what the Xbase++ docs says:

<snipet>
All graphic output occurs in a presentation space. For the output to be 
visible, the presentation space must be associated with an output device 
(a presentation space by itself is useless)
</snipet>

Then if you want to use an owner drawn presentation it must to be 
created using a PS linked to, ie XbpBitmap() or another Xbp or 
oXbp:lockPS().

Fraternally
Beling


Em 07/04/2018 17:29, Jim Lee escreveu:
> you have a o:lockPS() and a XbpPresSpace() which is different.
> you try to draw into o:DrawingArea which is not recommend. use a XbpStatic
> as Parent
>
>
Carlos a Beling Re: GraBitBlt() Question
on Wed, 11 Apr 2018 12:21:26 -0300
Good afternon.
After the kind Mr Jim's answer of my questions about GraBitBlt() I tried 
to understand best its behavior and of oBitmap:draw() and oIcon:draw().

Searching in the NGs I found that some time ago Mr Till clarifyed in the 
Public Xbase++ Gui (03.05.2002) the behavior of the constants used in 
the parameter <nRasterOP> of GraBitBlt() (please see them in the 
attached message Re_Parameter_nRasterOp_of_GraBitBlt().eml).

Then I tryed to see how they really works and wrote a simple test 
program that makes me to think that showed to me that it has something 
wrong or in my understanding about they or in the code of the testing 
program attached.

Please, does someone know what is wrong and  how to correct it?
I am using the Xbase++ version 2.00.875.

Fraternally
Beling

Em 07/04/2018 17:29, Jim Lee escreveu:
> you have a o:lockPS() and a XbpPresSpace() which is different.
> you try to draw into o:DrawingArea which is not recommend. use a XbpStatic
> as Parent
>
>


Re_ Parameter_nRasterOP_of_GraBitBlt().eml
TestPS.zip
Jim LeeRe: GraBitBlt() Question
on Thu, 12 Apr 2018 02:18:26 +0200
hi,

Icon Arrow32x32.ico is not include in your Demo.
if you cover you Demo with other App Windows there is no (automatic) 
repaint.

* ------------------------------------------------------------------------------------------------------------- 
*

you 1st make a empty Bitmap and assign a (real) Presspace OK
next you load Icon OK
than you try to access o:DrawingArea ...

> oDraw      := oApp:drawingArea:lockPS()
> e_draw(oBitmap, oIco, oDraw, nCount, nY)
> oPS := oBitmap:presSpace()

NO !!! you have already assign (real) XbpPresspace Object to empty Bitmap !

> oPS:SetColor(GraMakeRGBColor({255, 0, 0}))

never saw that Syntax.
how Color work with Presspace see later

> oIco:draw(oPS, {(200 - oIco:xSize), 0, 200, oIco:Ysize})

i guess you want to draw Icon into empty Bitmap ... wrong Presspace

> oBitmap:draw(oDraw,

you try to draw Bitmap into o:DrawingArea ...

> GraBitBlt(oDraw, oPS,

and now you try it with 2 x MicroPS ... total wrong Way

* ------------------------------------------------------------------------------------------------------------- 
*

1.) use a XbpStatic
2.) use XbpStatic Callback Slot o:Draw -> Ownerdraw

   oStatic:drawMode := XBP_DRAW_OWNER
   oStatic:draw := {|oPS, aInfo, oSelf| MyPaint(oPS, aInfo, oSelf, 
Other_Parameter) }

now you have the right oPS and xbeP_Draw Event will send by OS() if need to 
activate Callback Codebock (MyPaint)

FUNCTION MyPaint(oPS, aInfo, oSelf, Other_Parameter)
LOCAL nXDest  := aInfo[ XBP_DRAWINFO_RECT ] [ 1 ]
LOCAL nYDest  := aInfo[ XBP_DRAWINFO_RECT ] [ 2 ]
LOCAL nWidth  := aInfo[ XBP_DRAWINFO_RECT ] [ 3 ]
LOCAL nHeight := aInfo[ XBP_DRAWINFO_RECT ] [ 4 ]
LOCAL aAAttrs := ARRAY( GRA_AA_COUNT )  Attribut Area   -> AA
LOCAL aASttrs := ARRAY( GRA_AS_COUNT )  Attribut String -> AS
LOCAL aPrev
LOCAL cText

UnUsed(Other_Parameter)

    Attribut Area  Color
   IF BAND( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_SELECTED ) != 0
      aAAttrs[ GRA_AA_COLOR ] := XBPSYSCLR_HILITEBACKGROUND
   ELSE
      aAAttrs[ GRA_AA_COLOR ] := XBPSYSCLR_WINDOW
   ENDIF
   GraSetAttrArea( oPS, aAAttrs )
   GraBox( oPS, { nXDest, nYDest }, { nWidth, nHeight }, GRA_FILL )

    draw Bitmap / Icon after Backgound Color or visual Style
    oBitmap:Draw(oPS ... )
    oIcon:Draw(oPS ... )

    assign Font Object
    oPS:SetFont(oFont)

    Attribut String Color / Align
   aASttrs[ GRA_AS_COLOR ] := GRA_CLR_BLACK
   aASttrs[ GRA_AS_VERTALIGN ] := GRA_VALIGN_HALF
   aPrev := GRASETATTRSTRING( oPS, aASttrs )

    most XbParts have o:Caption or use "Other_Parameter"
   cText := oSelf:Caption

   GraCaptionStr( oPS, { nXDest, nYDest }, ;
                       { nWidth, nHeight }, ;
                         cText, ;
                         XBPALIGN_VCENTER+XBPALIGN_HCENTER )
    reset Attribut
   GRASETATTRSTRING( oPS, aPrev )


    Draw the focus box, if the object has the input focus
   IF Band( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_FOCUS ) != 0
      GraFocusRect( oPS, { nXDest, nYDest }, { nWidth, nHeight } )
   ENDIF

 NEED .F. !!!
 if .T. OS() will have Control

RETURN .F.
Carlos a Beling Re: GraBitBlt() Question
on Thu, 12 Apr 2018 10:01:55 -0300
Hello Jim.
Good morning.
Manyt thanks again.
Here is the complete test attached. Sorry by my fault.
Really I was not concerned about the screen's repaint because I only 
want to know the result about the use of the parameter <nRasterOp> in 
the method oBitmap:draw() and the function GraBitBlt().

Fraternally
Beling

Em 11/04/2018 21:18, Jim Lee escreveu:
> hi,
>
> Icon Arrow32x32.ico is not include in your Demo.
> if you cover you Demo with other App Windows there is no (automatic)
> repaint.
>
> * -------------------------------------------------------------------------------------------------------------
> *
>
> you 1st make a empty Bitmap and assign a (real) Presspace OK
> next you load Icon OK
> than you try to access o:DrawingArea ...
>
>> oDraw      := oApp:drawingArea:lockPS()
>> e_draw(oBitmap, oIco, oDraw, nCount, nY)
>> oPS := oBitmap:presSpace()
>
> NO !!! you have already assign (real) XbpPresspace Object to empty Bitmap !
>
>> oPS:SetColor(GraMakeRGBColor({255, 0, 0}))
>
> never saw that Syntax.
> how Color work with Presspace see later
>
>> oIco:draw(oPS, {(200 - oIco:xSize), 0, 200, oIco:Ysize})
>
> i guess you want to draw Icon into empty Bitmap ... wrong Presspace
>
>> oBitmap:draw(oDraw,
>
> you try to draw Bitmap into o:DrawingArea ...
>
>> GraBitBlt(oDraw, oPS,
>
> and now you try it with 2 x MicroPS ... total wrong Way
>
> * -------------------------------------------------------------------------------------------------------------
> *
>
> 1.) use a XbpStatic
> 2.) use XbpStatic Callback Slot o:Draw -> Ownerdraw
>
>     oStatic:drawMode := XBP_DRAW_OWNER
>     oStatic:draw := {|oPS, aInfo, oSelf| MyPaint(oPS, aInfo, oSelf,
> Other_Parameter) }
>
> now you have the right oPS and xbeP_Draw Event will send by OS() if need to
> activate Callback Codebock (MyPaint)
>
> FUNCTION MyPaint(oPS, aInfo, oSelf, Other_Parameter)
> LOCAL nXDest  := aInfo[ XBP_DRAWINFO_RECT ] [ 1 ]
> LOCAL nYDest  := aInfo[ XBP_DRAWINFO_RECT ] [ 2 ]
> LOCAL nWidth  := aInfo[ XBP_DRAWINFO_RECT ] [ 3 ]
> LOCAL nHeight := aInfo[ XBP_DRAWINFO_RECT ] [ 4 ]
> LOCAL aAAttrs := ARRAY( GRA_AA_COUNT )  Attribut Area   -> AA
> LOCAL aASttrs := ARRAY( GRA_AS_COUNT )  Attribut String -> AS
> LOCAL aPrev
> LOCAL cText
>
> UnUsed(Other_Parameter)
>
>      Attribut Area  Color
>     IF BAND( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_SELECTED ) != 0
>        aAAttrs[ GRA_AA_COLOR ] := XBPSYSCLR_HILITEBACKGROUND
>     ELSE
>        aAAttrs[ GRA_AA_COLOR ] := XBPSYSCLR_WINDOW
>     ENDIF
>     GraSetAttrArea( oPS, aAAttrs )
>     GraBox( oPS, { nXDest, nYDest }, { nWidth, nHeight }, GRA_FILL )
>
>      draw Bitmap / Icon after Backgound Color or visual Style
>      oBitmap:Draw(oPS ... )
>      oIcon:Draw(oPS ... )
>
>      assign Font Object
>      oPS:SetFont(oFont)
>
>      Attribut String Color / Align
>     aASttrs[ GRA_AS_COLOR ] := GRA_CLR_BLACK
>     aASttrs[ GRA_AS_VERTALIGN ] := GRA_VALIGN_HALF
>     aPrev := GRASETATTRSTRING( oPS, aASttrs )
>
>      most XbParts have o:Caption or use "Other_Parameter"
>     cText := oSelf:Caption
>
>     GraCaptionStr( oPS, { nXDest, nYDest }, ;
>                         { nWidth, nHeight }, ;
>                           cText, ;
>                           XBPALIGN_VCENTER+XBPALIGN_HCENTER )
>      reset Attribut
>     GRASETATTRSTRING( oPS, aPrev )
>
>
>      Draw the focus box, if the object has the input focus
>     IF Band( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_FOCUS ) != 0
>        GraFocusRect( oPS, { nXDest, nYDest }, { nWidth, nHeight } )
>     ENDIF
>
>  NEED .F. !!!
>  if .T. OS() will have Control
> 
> RETURN .F.
>
>


TestPS.zip
Jim LeeRe: GraBitBlt() Question
on Fri, 13 Apr 2018 05:11:58 +0200
> Here is the complete test attached. Sorry by my fault.

but it is still same not working Code

> I only  want to know the result about the use of the parameter <nRasterOp> 
> in
> the method oBitmap:draw() and the function GraBitBlt().

Result is bad when used wrong Code ... to much "Presspace" and mixing it ... 
NO
try Ownerdraw as i say and use a XbPart, NOT o:DrawingArea, as Parent for 
GRA Function

---

you normal just overpaint Background with GraBox(), than you overpaint 
Background with GraCaptionStr()
or oBitmap:Draw() / Icon:Draw() but none touch Area of other so you do not 
"mix" so there no need to use other than default nRasterOP.
Carlos a Beling Re: GraBitBlt() Question
on Fri, 13 Apr 2018 16:35:57 -0300
Hello.
Good afternoon.

I tested again the program as Jim advised earlyer and I saw that:
. rendering XbpBitmap() in xbpStatic():lockPS() produces the same image 
rendered in Drawingarea:lockPS()
. XbpBitmap():draw() shows do not working in the same way as GraBitBlt() 
does
. some GRA_BLT_ROP_... seem do not work: they show up in black color
. XbpBitmap():draw() using GRA_BLT_ROP_SRCCOPY did not worked fine using 
some colors in XbpStatic():lockPS()

I included in the attached TestPS.zip the program
  ..\Xbase++\source\samples\apps\imgview\ImgView.prg that uses 
XbpPresSpace():new():create( oDlg:drawingArea:winDevice() ) for 
rendering image.

Could anybody confirm these observations running the testing prg and, if 
possible, correct the program? In it there lines that can to be used for 
comproving (or negating) my understanding.

Fraternally
Beling


Em 13/04/2018 00:11, Jim Lee escreveu:
>> Here is the complete test attached. Sorry by my fault.
>
> but it is still same not working Code
>
>> I only  want to know the result about the use of the parameter <nRasterOp>
>> in
>> the method oBitmap:draw() and the function GraBitBlt().
>
> Result is bad when used wrong Code ... to much "Presspace" and mixing it ...
> NO
> try Ownerdraw as i say and use a XbPart, NOT o:DrawingArea, as Parent for
> GRA Function
>
> ---
>
> you normal just overpaint Background with GraBox(), than you overpaint
> Background with GraCaptionStr()
> or oBitmap:Draw() / Icon:Draw() but none touch Area of other so you do not
> "mix" so there no need to use other than default nRasterOP.
>
>
>


TestPS.zip
Jim LeeRe: GraBitBlt() Question
on Sat, 14 Apr 2018 07:29:04 +0200
> I included in the attached TestPS.zip the program
>  ..\Xbase++\source\samples\apps\imgview\ImgView.prg that uses
> XbpPresSpace():new():create( oDlg:drawingArea:winDevice() ) for
> rendering image.

the o:Paint Callback Slot does not have oPS only

<aRect> := { nX1, nY1, nX2, nY2 }

it include oImage:draw(oPS ... ) where oPS ist a (full) Presentationspace.
as it only display 1 Bitmap there is no "mix" -> no GRA_BLT_ROP_*

here a Sample where GRA is "mixing" using GraBitBlt() and different 
GRA_BLT_ROP_*

---

#include "Gra.ch"
#include "Inkey.ch"

PROCEDURE Main
LOCAL aAttrArc, aAttrBox, aAttrTxt
LOCAL nX0 , nY0 , nX1, nY1, nX2, nY2, nRadius
LOCAL aROP := GetROP()
LOCAL aColor := GetColorBG()
LOCAL i,iMax := LEN(aROP)
LOCAL j,jMax := LEN(aColor)
LOCAL nROP, cText, nKey

   aAttrBox := ARRAY( GRA_AA_COUNT )
   aAttrBox[ GRA_AA_SYMBOL ] := GRA_SYM_DIAG2
   aAttrBox[ GRA_AA_COLOR  ] := GRA_CLR_RED

   aAttrArc := ARRAY( GRA_AA_COUNT )
   aAttrArc[ GRA_AA_SYMBOL ] := GRA_SYM_DENSE3
   aAttrArc[ GRA_AA_COLOR  ] := GRA_CLR_BLUE

   aAttrTxt := ARRAY( GRA_AS_COUNT )

   nRadius :=  40
   nX0     :=  20
   nY0     := 140
   nX1     :=  90

   nY1     := 240
   nX2     := nX1 + nRadius
   nY2     := nY1 + nRadius

   FOR j := 1 TO jMax
      FOR i := 1 TO iMax

         SetColor(aColor[j])
         CLS

         GraSetAttrArea( NIL, aAttrBox )
         GraBox( NIL, {nX0, nY0}, {nX1, nY1}, GRA_OUTLINEFILL )

         GraSetAttrArea( NIL, aAttrArc )
         GraArc( NIL, {nX1,nY1}, nRadius,,,, GRA_OUTLINEFILL  )

         * --------------------------------------------------- *

         cText := aROP[i][1]
         nROP  := aROP[i][2]

         GraBitBlt(NIL , , { nX0+150, nY0, ;
                             nX2+150, nY2 }, ;
                           { nX0, nY0 }, nROP )


         aAttrTxt[ GRA_AS_COLOR ] := IF(SUBSTR(aColor[j],1,1)="W",;
                                               GRA_CLR_WHITE,;
                                               GRA_CLR_BLACK)

         GraSetAttrString(NIL , aAttrTxt)
         GraStringAt( NIL, {10, 10}, cText )

         nKey := Inkey(1)
         IF nKey = K_ESC
            QUIT
         ENDIF
      NEXT
   NEXT

RETURN

FUNCTION GetROP()
LOCAL aRet := {}

   AADD(aRet,{"GRA_BLT_ROP_SRCCOPY    ", GRA_BLT_ROP_SRCCOPY    })
   AADD(aRet,{"GRA_BLT_ROP_SRCPAINT   ", GRA_BLT_ROP_SRCPAINT   })
   AADD(aRet,{"GRA_BLT_ROP_SRCAND     ", GRA_BLT_ROP_SRCAND     })
   AADD(aRet,{"GRA_BLT_ROP_SRCINVERT  ", GRA_BLT_ROP_SRCINVERT  })
   AADD(aRet,{"GRA_BLT_ROP_SRCERASE   ", GRA_BLT_ROP_SRCERASE   })
   AADD(aRet,{"GRA_BLT_ROP_NOTSRCCOPY ", GRA_BLT_ROP_NOTSRCCOPY })
   AADD(aRet,{"GRA_BLT_ROP_NOTSRCERASE", GRA_BLT_ROP_NOTSRCERASE})
   AADD(aRet,{"GRA_BLT_ROP_MERGECOPY  ", GRA_BLT_ROP_MERGECOPY  })
   AADD(aRet,{"GRA_BLT_ROP_MERGEPAINT ", GRA_BLT_ROP_MERGEPAINT })
   AADD(aRet,{"GRA_BLT_ROP_PATCOPY    ", GRA_BLT_ROP_PATCOPY    })
   AADD(aRet,{"GRA_BLT_ROP_PATPAINT   ", GRA_BLT_ROP_PATPAINT   })
   AADD(aRet,{"GRA_BLT_ROP_PATINVERT  ", GRA_BLT_ROP_PATINVERT  })
   AADD(aRet,{"GRA_BLT_ROP_DSTINVERT  ", GRA_BLT_ROP_DSTINVERT  })
   AADD(aRet,{"GRA_BLT_ROP_ZERO       ", GRA_BLT_ROP_ZERO       })
   AADD(aRet,{"GRA_BLT_ROP_ONE        ", GRA_BLT_ROP_ONE        })

RETURN aRet

FUNCTION GetColorBG()
LOCAL aRet := {}

   AADD(aRet,"W/N ")
   AADD(aRet,"W/B ")
   AADD(aRet,"N/G ")
   AADD(aRet,"N/BG")
   AADD(aRet,"N/R ")
   AADD(aRet,"N/RB")
   AADD(aRet,"N/GR")
   AADD(aRet,"N/W ")

RETURN aRet



*
Carlos a Beling Re: GraBitBlt() Question
on Sat, 14 Apr 2018 16:17:20 -0300
Hello Jim.
Good afternoon.
Many thanks again.
Sorry me come back again.
You used oCrt:presspace() that is built in in XbpCrt() and you wrote 
directly in it (what should to be tha same as to write in 
oDrawingArea:lockPS() and it seems not to be the same thing).
Could you please (or any other friend), if feasible - or possible, to 
correct the example program that I posted or to confirm that we have a 
problem with oBitmap:draw() and GraBitBlt() function?

Fraternally
Beling



Em 14/04/2018 02:29, Jim Lee escreveu:
>> I included in the attached TestPS.zip the program
>>   ..\Xbase++\source\samples\apps\imgview\ImgView.prg that uses
>> XbpPresSpace():new():create( oDlg:drawingArea:winDevice() ) for
>> rendering image.
>
> the o:Paint Callback Slot does not have oPS only
>
> <aRect> := { nX1, nY1, nX2, nY2 }
>
> it include oImage:draw(oPS ... ) where oPS ist a (full) Presentationspace.
> as it only display 1 Bitmap there is no "mix" -> no GRA_BLT_ROP_*
>
> here a Sample where GRA is "mixing" using GraBitBlt() and different
> GRA_BLT_ROP_*
>
> ---
>
> #include "Gra.ch"
> #include "Inkey.ch"
>
> PROCEDURE Main
> LOCAL aAttrArc, aAttrBox, aAttrTxt
> LOCAL nX0 , nY0 , nX1, nY1, nX2, nY2, nRadius
> LOCAL aROP := GetROP()
> LOCAL aColor := GetColorBG()
> LOCAL i,iMax := LEN(aROP)
> LOCAL j,jMax := LEN(aColor)
> LOCAL nROP, cText, nKey
>
>     aAttrBox := ARRAY( GRA_AA_COUNT )
>     aAttrBox[ GRA_AA_SYMBOL ] := GRA_SYM_DIAG2
>     aAttrBox[ GRA_AA_COLOR  ] := GRA_CLR_RED
>
>     aAttrArc := ARRAY( GRA_AA_COUNT )
>     aAttrArc[ GRA_AA_SYMBOL ] := GRA_SYM_DENSE3
>     aAttrArc[ GRA_AA_COLOR  ] := GRA_CLR_BLUE
>
>     aAttrTxt := ARRAY( GRA_AS_COUNT )
>
>     nRadius :=  40
>     nX0     :=  20
>     nY0     := 140
>     nX1     :=  90
>
>     nY1     := 240
>     nX2     := nX1 + nRadius
>     nY2     := nY1 + nRadius
>
>     FOR j := 1 TO jMax
>        FOR i := 1 TO iMax
>
>           SetColor(aColor[j])
>           CLS
>
>           GraSetAttrArea( NIL, aAttrBox )
>           GraBox( NIL, {nX0, nY0}, {nX1, nY1}, GRA_OUTLINEFILL )
>
>           GraSetAttrArea( NIL, aAttrArc )
>           GraArc( NIL, {nX1,nY1}, nRadius,,,, GRA_OUTLINEFILL  )
>
>           * --------------------------------------------------- *
>
>           cText := aROP[i][1]
>           nROP  := aROP[i][2]
>
>           GraBitBlt(NIL , , { nX0+150, nY0, ;
>                               nX2+150, nY2 }, ;
>                             { nX0, nY0 }, nROP )
>
>
>           aAttrTxt[ GRA_AS_COLOR ] := IF(SUBSTR(aColor[j],1,1)="W",;
>                                                 GRA_CLR_WHITE,;
>                                                 GRA_CLR_BLACK)
>
>           GraSetAttrString(NIL , aAttrTxt)
>           GraStringAt( NIL, {10, 10}, cText )
>
>           nKey := Inkey(1)
>           IF nKey = K_ESC
>              QUIT
>           ENDIF
>        NEXT
>     NEXT
>
> RETURN
>
> FUNCTION GetROP()
> LOCAL aRet := {}
>
>     AADD(aRet,{"GRA_BLT_ROP_SRCCOPY    ", GRA_BLT_ROP_SRCCOPY    })
>     AADD(aRet,{"GRA_BLT_ROP_SRCPAINT   ", GRA_BLT_ROP_SRCPAINT   })
>     AADD(aRet,{"GRA_BLT_ROP_SRCAND     ", GRA_BLT_ROP_SRCAND     })
>     AADD(aRet,{"GRA_BLT_ROP_SRCINVERT  ", GRA_BLT_ROP_SRCINVERT  })
>     AADD(aRet,{"GRA_BLT_ROP_SRCERASE   ", GRA_BLT_ROP_SRCERASE   })
>     AADD(aRet,{"GRA_BLT_ROP_NOTSRCCOPY ", GRA_BLT_ROP_NOTSRCCOPY })
>     AADD(aRet,{"GRA_BLT_ROP_NOTSRCERASE", GRA_BLT_ROP_NOTSRCERASE})
>     AADD(aRet,{"GRA_BLT_ROP_MERGECOPY  ", GRA_BLT_ROP_MERGECOPY  })
>     AADD(aRet,{"GRA_BLT_ROP_MERGEPAINT ", GRA_BLT_ROP_MERGEPAINT })
>     AADD(aRet,{"GRA_BLT_ROP_PATCOPY    ", GRA_BLT_ROP_PATCOPY    })
>     AADD(aRet,{"GRA_BLT_ROP_PATPAINT   ", GRA_BLT_ROP_PATPAINT   })
>     AADD(aRet,{"GRA_BLT_ROP_PATINVERT  ", GRA_BLT_ROP_PATINVERT  })
>     AADD(aRet,{"GRA_BLT_ROP_DSTINVERT  ", GRA_BLT_ROP_DSTINVERT  })
>     AADD(aRet,{"GRA_BLT_ROP_ZERO       ", GRA_BLT_ROP_ZERO       })
>     AADD(aRet,{"GRA_BLT_ROP_ONE        ", GRA_BLT_ROP_ONE        })
>
> RETURN aRet
>
> FUNCTION GetColorBG()
> LOCAL aRet := {}
>
>     AADD(aRet,"W/N ")
>     AADD(aRet,"W/B ")
>     AADD(aRet,"N/G ")
>     AADD(aRet,"N/BG")
>     AADD(aRet,"N/R ")
>     AADD(aRet,"N/RB")
>     AADD(aRet,"N/GR")
>     AADD(aRet,"N/W ")
>
> RETURN aRet
>
> *
> *
> *
>
>
Jim LeeRe: GraBitBlt() Question
on Mon, 16 Apr 2018 00:51:48 +0200
this App use a (big) Image -> small Image
it show all possible ROP Combination

* ------------------------------------------------------- *

#include "Gra.ch"
#include "Xbp.ch"
#include "Appevent.ch"

PROCEDURE Appsys
RETURN

PROCEDURE Main(cFile)
LOCAL lExit := .F.
LOCAL nEvent, oXbp, mp1, mp2
LOCAL oDlg
LOCAL aSize := {600,600}
LOCAL aPos  := {0,0}
LOCAL nTime := 100
LOCAL aXbpSize := {256,256}
LOCAL oPb
LOCAL nBGClr
LOCAL oStat
LOCAL oStat2
LOCAL oBMP
LOCAL oBild

   IF EMPTY(cFile)
      Msgbox("need BMP  JPG  PNG file","Error no file")
      QUIT
   ENDIF

   oDlg := XbpDialog():New(AppDesktop() ,,aPos,aSize,,.F.)
   oDlg:tasklist  := .T.
   oDlg:title     := "make best Tumbnail"
   oDlg:icon      := 1
   oDlg:Close := {|| lExit := .T.}
   oDlg:Create()

   CenterControl(oDlg)
   aSize := oDlg:drawingArea:CurrentSize()

   oStat2 := XbpStatic():new( oDlg:drawingArea,,{10,50} ,{aSize[1]-20,40})
   oStat2:type     := XBPSTATIC_TYPE_TEXT
   oStat2:options  := XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_CENTER
   oStat2:caption  := cFile
   oStat2:create()

   oBMP  := XbpBitmap():new():create()
   IF oBMP:loadFile(cFile)
      oBild := BMP2BMP2( oBMP, aXbpSize ,IF(oBMP:xSize>64,.T.,.F.),oStat2 )
   ENDIF

   oStat := XbpStatic():new( oDlg:drawingArea,, {0,0} ,aXbpSize)
   oStat:type     := XBPSTATIC_TYPE_BITMAP
   oStat:caption  := oBild
   oStat:create()
   CenterControl(oStat,oDlg)

   oPb := XbpPushButton():new(oDlg:drawingArea,,{10,10}, {aSize[1]-20,40} )
   oPb:caption := "next"
   oPb:create()
   oPb:activate:= {|| ;
      oBild := BMP2BMP2( oBMP, aXbpSize ,IF(oBMP:xSize>64,.T.,.F.), 
oStat2 ),;
      oStat:Setcaption(oBild) }

   oDlg:show()
   SetAppWindow(oDlg)
   SetAppFocus(oDlg)

   nEvent := xbe_None
   DO WHILE !lExit
      nEvent := AppEvent ( @mp1, @mp2, @oXbp, nTime )
      DO CASE
          timeout
         CASE nEvent == xbe_None
            PostAppEvent(xbeP_Activate,,,oPb)

         CASE nEvent == xbeP_Quit
            EXIT

         CASE nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC
            EXIT
      OTHERWISE
         oXbp:HandleEvent ( nEvent, mp1, mp2 )
      ENDCASE
   ENDDO

   oDlg:Destroy()
RETURN

STATIC FUNCTION BMP2BMP2( oBMP, aXbpSize,lBig2small, oStat2  )
LOCAL oHuge
LOCAL oTiny
LOCAL oPS
LOCAL oRet
LOCAL nBits
LOCAL nPlanes
LOCAL nBGClr

STATIC nWahl := 0

  IF aXbpSize[ 2 ] > 0
      oHuge    := oBMP
      nBits    := oBMP:bits
      nPlanes  := oBMP:planes
      nBGClr   := oBMP:getDefaultBgColor()

      oPS := XBPPRESSPACE() :new()
      //Create a small bitmap to fit in our XbpStatic
      oTiny := XBPBITMAP():New():Create(oPS)

      IF lBig2small
         oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ], nPlanes, nBits )
         oTiny:transparentClr := nBGClr
      ELSE
         oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ] )
      ENDIF
      oTiny:presSpace( oPS )

      //Copie and resize the huge bitmap to the small bitmap
      IF lBig2small
         nWahl++
         IF nWahl > 48
            nWahl := 1
         ENDIF

         DO CASE
            CASE nWahl =  1 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] } )                                              ; 
oStat2:setcaption("GRA_BLT_BBO_IGNORE")
            CASE nWahl =  2 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  3 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  4 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  5 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  6 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  7 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_IGNORE")
            CASE nWahl =  8 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_IGNORE")
            CASE nWahl =  9 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 10 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 11 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 12 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 13 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 14 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 15 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_IGNORE")
            CASE nWahl = 16 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_IGNORE ) ; 
oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_IGNORE")

            CASE nWahl = 17 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] } )                                              ; 
oStat2:setcaption("GRA_BLT_BBO_OR")
            CASE nWahl = 18 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_OR")
            CASE nWahl = 19 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_OR")
            CASE nWahl = 20 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_OR")
            CASE nWahl = 21 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_OR")
            CASE nWahl = 22 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_OR")
            CASE nWahl = 23 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_OR")
            CASE nWahl = 24 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_OR")
            CASE nWahl = 25 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_OR")
            CASE nWahl = 26 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_OR")
            CASE nWahl = 27 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_OR")
            CASE nWahl = 28 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_OR")
            CASE nWahl = 29 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_OR")
            CASE nWahl = 30 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_OR")
            CASE nWahl = 31 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_OR")
            CASE nWahl = 32 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_OR )     ; 
oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_OR")

            CASE nWahl = 33 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] } )                                              ; 
oStat2:setcaption("GRA_BLT_BBO_AND")
            CASE nWahl = 34 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_AND")
            CASE nWahl = 35 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_AND")
            CASE nWahl = 36 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_AND")
            CASE nWahl = 37 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_AND")
            CASE nWahl = 38 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_AND")
            CASE nWahl = 39 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_AND")
            CASE nWahl = 40 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_AND")
            CASE nWahl = 41 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_AND")
            CASE nWahl = 42 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_AND")
            CASE nWahl = 43 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_AND")
            CASE nWahl = 44 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_AND")
            CASE nWahl = 45 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_AND")
            CASE nWahl = 46 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_AND")
            CASE nWahl = 47 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_AND")
            CASE nWahl = 48 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1], 
aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_AND )    ; 
oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_AND")

         ENDCASE
      ELSE
         oHuge:Draw( oPS, { 0, 0, aXbpSize[1], aXbpSize[2] },,, 
GRA_BLT_BBO_IGNORE  )
      ENDIF
      oRet := oTiny
   ELSE
      oRet := oBMP
   ENDIF

RETURN oRet

 eof
*
Carlos a Beling Re: GraBitBlt() Question
on Wed, 18 Apr 2018 11:48:44 -0300
Hello Jim:
good morning.
Many thanks again and again.
I made little changes in the program and it is running - please take a 
look at it.
Really if you :draw() in a very large PS you have problem.
This makes to think the real utility of the parameter oBMP:draw(oPS, 
<aTargetRect>) because if I define the target area to be used and the 
size of oPS  is very large, it might not to be important.
Another thing is that some <nRaterOP> seems do not work fine.


Fraternally
Beling

Em 15/04/2018 19:51, Jim Lee escreveu:
> this App use a (big) Image -> small Image
> it show all possible ROP Combination
>
> * ------------------------------------------------------- *
>
> #include "Gra.ch"
> #include "Xbp.ch"
> #include "Appevent.ch"
>
> PROCEDURE Appsys
> RETURN
>
> PROCEDURE Main(cFile)
> LOCAL lExit := .F.
> LOCAL nEvent, oXbp, mp1, mp2
> LOCAL oDlg
> LOCAL aSize := {600,600}
> LOCAL aPos  := {0,0}
> LOCAL nTime := 100
> LOCAL aXbpSize := {256,256}
> LOCAL oPb
> LOCAL nBGClr
> LOCAL oStat
> LOCAL oStat2
> LOCAL oBMP
> LOCAL oBild
>
>     IF EMPTY(cFile)
>        Msgbox("need BMP  JPG  PNG file","Error no file")
>        QUIT
>     ENDIF
>
>     oDlg := XbpDialog():New(AppDesktop() ,,aPos,aSize,,.F.)
>     oDlg:tasklist  := .T.
>     oDlg:title     := "make best Tumbnail"
>     oDlg:icon      := 1
>     oDlg:Close := {|| lExit := .T.}
>     oDlg:Create()
>
>     CenterControl(oDlg)
>     aSize := oDlg:drawingArea:CurrentSize()
>
>     oStat2 := XbpStatic():new( oDlg:drawingArea,,{10,50} ,{aSize[1]-20,40})
>     oStat2:type     := XBPSTATIC_TYPE_TEXT
>     oStat2:options  := XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_CENTER
>     oStat2:caption  := cFile
>     oStat2:create()
>
>     oBMP  := XbpBitmap():new():create()
>     IF oBMP:loadFile(cFile)
>        oBild := BMP2BMP2( oBMP, aXbpSize ,IF(oBMP:xSize>64,.T.,.F.),oStat2 )
>     ENDIF
>
>     oStat := XbpStatic():new( oDlg:drawingArea,, {0,0} ,aXbpSize)
>     oStat:type     := XBPSTATIC_TYPE_BITMAP
>     oStat:caption  := oBild
>     oStat:create()
>     CenterControl(oStat,oDlg)
>
>     oPb := XbpPushButton():new(oDlg:drawingArea,,{10,10}, {aSize[1]-20,40} )
>     oPb:caption := "next"
>     oPb:create()
>     oPb:activate:= {|| ;
>        oBild := BMP2BMP2( oBMP, aXbpSize ,IF(oBMP:xSize>64,.T.,.F.),
> oStat2 ),;
>        oStat:Setcaption(oBild) }
>
>     oDlg:show()
>     SetAppWindow(oDlg)
>     SetAppFocus(oDlg)
>
>     nEvent := xbe_None
>     DO WHILE !lExit
>        nEvent := AppEvent ( @mp1, @mp2, @oXbp, nTime )
>        DO CASE
>            timeout
>           CASE nEvent == xbe_None
>              PostAppEvent(xbeP_Activate,,,oPb)
>
>           CASE nEvent == xbeP_Quit
>              EXIT
>
>           CASE nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC
>              EXIT
>        OTHERWISE
>           oXbp:HandleEvent ( nEvent, mp1, mp2 )
>        ENDCASE
>     ENDDO
>
>     oDlg:Destroy()
> RETURN
>
> STATIC FUNCTION BMP2BMP2( oBMP, aXbpSize,lBig2small, oStat2  )
> LOCAL oHuge
> LOCAL oTiny
> LOCAL oPS
> LOCAL oRet
> LOCAL nBits
> LOCAL nPlanes
> LOCAL nBGClr
>
> STATIC nWahl := 0
>
>    IF aXbpSize[ 2 ] > 0
>        oHuge    := oBMP
>        nBits    := oBMP:bits
>        nPlanes  := oBMP:planes
>        nBGClr   := oBMP:getDefaultBgColor()
>
>        oPS := XBPPRESSPACE() :new()
>        //Create a small bitmap to fit in our XbpStatic
>        oTiny := XBPBITMAP():New():Create(oPS)
>
>        IF lBig2small
>           oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ], nPlanes, nBits )
>           oTiny:transparentClr := nBGClr
>        ELSE
>           oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ] )
>        ENDIF
>        oTiny:presSpace( oPS )
>
>        //Copie and resize the huge bitmap to the small bitmap
>        IF lBig2small
>           nWahl++
>           IF nWahl > 48
>              nWahl := 1
>           ENDIF
>
>           DO CASE
>              CASE nWahl =  1 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] } )                                              ;
> oStat2:setcaption("GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  2 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  3 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  4 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  5 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  6 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  7 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  8 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_IGNORE")
>              CASE nWahl =  9 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 10 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 11 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 12 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 13 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 14 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 15 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_IGNORE")
>              CASE nWahl = 16 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_IGNORE ) ;
> oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_IGNORE")
>
>              CASE nWahl = 17 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] } )                                              ;
> oStat2:setcaption("GRA_BLT_BBO_OR")
>              CASE nWahl = 18 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_OR")
>              CASE nWahl = 19 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_OR")
>              CASE nWahl = 20 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_OR")
>              CASE nWahl = 21 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_OR")
>              CASE nWahl = 22 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_OR")
>              CASE nWahl = 23 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_OR")
>              CASE nWahl = 24 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_OR")
>              CASE nWahl = 25 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_OR")
>              CASE nWahl = 26 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_OR")
>              CASE nWahl = 27 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_OR")
>              CASE nWahl = 28 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_OR")
>              CASE nWahl = 29 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_OR")
>              CASE nWahl = 30 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_OR")
>              CASE nWahl = 31 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_OR")
>              CASE nWahl = 32 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_OR )     ;
> oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_OR")
>
>              CASE nWahl = 33 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] } )                                              ;
> oStat2:setcaption("GRA_BLT_BBO_AND")
>              CASE nWahl = 34 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_SRCCOPY    , GRA_BLT_BBO_AND")
>              CASE nWahl = 35 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_SRCPAINT   , GRA_BLT_BBO_AND")
>              CASE nWahl = 36 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_SRCAND     , GRA_BLT_BBO_AND")
>              CASE nWahl = 37 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_SRCINVERT  , GRA_BLT_BBO_AND")
>              CASE nWahl = 38 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_SRCERASE   , GRA_BLT_BBO_AND")
>              CASE nWahl = 39 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCCOPY , GRA_BLT_BBO_AND")
>              CASE nWahl = 40 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_NOTSRCERASE, GRA_BLT_BBO_AND")
>              CASE nWahl = 41 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_MERGECOPY  , GRA_BLT_BBO_AND")
>              CASE nWahl = 42 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_MERGEPAINT , GRA_BLT_BBO_AND")
>              CASE nWahl = 43 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_PATCOPY    , GRA_BLT_BBO_AND")
>              CASE nWahl = 44 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_PATPAINT   , GRA_BLT_BBO_AND")
>              CASE nWahl = 45 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_PATINVERT  , GRA_BLT_BBO_AND")
>              CASE nWahl = 46 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_DSTINVERT  , GRA_BLT_BBO_AND")
>              CASE nWahl = 47 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_ZERO       , GRA_BLT_BBO_AND")
>              CASE nWahl = 48 ; oHuge:Draw( oPS, { 0, 0, aXbpSize[1],
> aXbpSize[2] },,GRA_BLT_ROP_ONE        , GRA_BLT_BBO_AND )    ;
> oStat2:setcaption("GRA_BLT_ROP_ONE        , GRA_BLT_BBO_AND")
>
>           ENDCASE
>        ELSE
>           oHuge:Draw( oPS, { 0, 0, aXbpSize[1], aXbpSize[2] },,,
> GRA_BLT_BBO_IGNORE  )
>        ENDIF
>        oRet := oTiny
>     ELSE
>        oRet := oBMP
>     ENDIF
>
> RETURN oRet
> *
> * eof
> *
>
>


testar.zip