autoscale

Moderator: Moderatoren

Antworten
Stephan Borst
Rookie
Rookie
Beiträge: 12
Registriert: Mi, 15. Jun 2016 10:33

autoscale

Beitrag von Stephan Borst »

Hi,

I need to convert some eXpress-code into basic xbp-parts.
Shouldn't be a problem, but I can't get the autoscale of a bitmap working.

eXpress-code:

Code: Alles auswählen

          @ 0,0 DCSTATIC;
                    EVAL {|o| o:setpos( {1,1} ) };
                  OBJECT oStatic;
                  PARENT oParent;
                    SIZE DCGUI_PARENTWIDTH-10,DCGUI_PARENTHEIGHT-10

                DCBITMAP cBild;
               AUTOSCALE;
                  OBJECT oBild;
                  PARENT oStatic
Basics of my xbp-parts:

Code: Alles auswählen

oGroup := createGroup( oParent,nLinks, nOben, breite, hohe )

oStatic := XbpStatic():new( oGroup,,{1,1} )
oStatic:type := XBPSTATIC_TYPE_BITMAP
oStatic:autoSize := .T.
oStatic:create()

oBitmap := XbpBitmap():new():create()
oBitmap:loadFile( Alltrim(cBild) )
oStatic:setCaption( oBitmap )

oBitmap := XbpBitmap():new():create()
oBitmap:loadFile( Alltrim(cBild) )
oStatic:setCaption( oBitmap )
Ideas and suggestions are welcome!

Regards, Stephan
Benutzeravatar
AUGE_OHR
Marvin
Marvin
Beiträge: 12903
Registriert: Do, 16. Mär 2006 7:55
Wohnort: Hamburg
Hat sich bedankt: 19 Mal
Danksagung erhalten: 44 Mal

Re: autoscale

Beitrag von AUGE_OHR »

hi,
Stephan Borst hat geschrieben: Di, 14. Nov 2017 19:21

Code: Alles auswählen

oStatic := XbpStatic():new( oGroup,,{1,1} )
oStatic:type := XBPSTATIC_TYPE_BITMAP
oStatic:autoSize := .T.     // does not work with Bitmap !
oStatic:create()

oBitmap := XbpBitmap():new():create()
oBitmap:loadFile( Alltrim(cBild) )

// need to resize Bitmap
oStatic:setCaption( BMP2BMP(oBitmap,oStatic:CurrentSize()) )
o:autoSize := .T. does not work with Bitmap !
you need to "resize" a Bitmap

Code: Alles auswählen

FUNCTION BMP2BMP(oBMP,aXbpSize)
LOCAL oHuge
LOCAL oTiny
LOCAL oPS
LOCAL oRet
LOCAL nBColor  := oBMP:getDefaultBgColor()
LOCAL aRGB

   IF aXbpSize[2] > 0
      oHuge := oBMP
      oPS := XbpPresSpace():new():Create()
      //Create a small bitmap to fit in our XbpStatic
      oTiny := XbpBitmap():New():Create()
      IF nBColor = 16777216
         aRGB := GraGetRGBIntensity(nBColor)
         oTiny:transparentClr := GraMakeRGBColor(aRGB)
      ELSE
         oTiny:transparentClr := nBColor
      ENDIF
      oTiny:Make(aXbpSize[1],aXbpSize[2])
      oTiny:presSpace(oPS)
      //Copie and resize the huge bitmap to the small bitmap
      oHuge:Draw(oPS,{0,0,aXbpSize[1],aXbpSize[2]},,,GRA_BLT_BBO_IGNORE)
      oRet := oTiny
      oBMP:destroy()
   ELSE
      oRet := oBMP
   ENDIF
RETURN oRet
gruss by OHR
Jimmy
Stephan Borst
Rookie
Rookie
Beiträge: 12
Registriert: Mi, 15. Jun 2016 10:33

Re: autoscale

Beitrag von Stephan Borst »

Nice!
First test seems to work. Thanks a lot.
Antworten