Page 1 of 1

Rezise Bitmaps

Posted: Mon Jan 26, 2009 7:19 pm
by Silvio
HOe I can resize a bitmap and Know his height and with to insert a prompt text ?

Re: Rezise Bitmaps

Posted: Mon Jan 26, 2009 7:37 pm
by Daniel Garcia-Gil
Silvio...

you can "stretch" bitmap into frame and use frame dimension ( height / width )

use BITMAP command or IMAGEN command and use ADJUST Clause...

Re: Rezise Bitmaps

Posted: Mon Jan 26, 2009 7:54 pm
by MGA

Re: Rezise Bitmaps

Posted: Mon Jan 26, 2009 9:16 pm
by Antonio Linares
Silvio,

It is is a bitmap control then you can do:

oBmp:SetSize( nNewWidth, nNewHeight )

to know its dimensions:

oBmp:nWidth
oBmp:nHeight

or is it a bitmap that you are managing in memory (and not a visible control) ?

Re: Rezise Bitmaps

Posted: Tue Jan 27, 2009 10:42 am
by ukoenig
Hello,

I want a Gradientfill on a resized BMP, but the results are not like expected :
The start-position of the 2. Color is not properly painted after resizing.
There is no change in the Grad-defines, only a resizing.

Given values with 100 %
Image

Resize to 31 % is OK
Image

Resize back to 80 % ( the white line must be centered but is shown twice )
Image

Code: Select all | Expand


//-------------  RESIZE BMP with  GRADIENT HOR / VERT -----------

// GRADIENT-BMP
// ---- only repainted if any Slider ( Horiz. or Vertical )- changed ----
REDEFINE BITMAP oBmp ID 130 ADJUST RESOURCE "Blanc" OF oFld:aDialogs[3]
oBmp:bPainted := { |hDC|  IIF( lHORZ = .T. .or. lVERT = .T., ;
     ( NEW_SIZE( oBMP ),lHORZ = .F., lVERT = .F. ), NIL ) }

// ----------------- Horizont-Slider ---------------------

REDEFINE SLIDER oSLIDER3 VAR nGRADHORZ OF oFld:aDialogs[3] ID 710;
HORIZONTAL ;
RIGHT DIRECTION ;
RANGE 0, 100 ;
ON CHANGE ( lHORZ := .T., lVERT:= .T., ;
      oGRADHORZ:Refresh(), ;
      nHORZ  := 6.2 * nGRADHORZ, ;
      oBMP:nWidth() := nHORZ, ;
      oBMP:Refresh() ) ;
      COLORS 128, 15977281, 128 ;
      MARKS 49 ;
      UPDATE

// % - Field
// ---------
REDEFINE GET oGRADHORZ VAR nGRADHORZ ID 715 PICTURE "999" OF oFld:aDialogs[3] UPDATE ;
VALID ( ( oGRADHORZ:Refresh(), oSlider3:Set(nGRADHORZ ), oSlider3:Refresh(), ;
      nHORZ  := 6.2 * nGRADHORZ, ;
      oBMP:nWidth() := nHORZ, ;
      oBMP:Refresh() ), .T. )

// ----------------- Vertical-Slider ---------------------

REDEFINE SLIDER oSLIDER4  VAR  nGRADVERT OF oFld:aDialogs[3] ID 700;
VERTICAL ;
RIGHT DIRECTION ;
RANGE 0, 100 ;
ON CHANGE ( lHORZ := .T., lVERT:= .T., ;
      oGRADVERT:Refresh(), ;
      nVERT  := 4.9 * nGRADVERT,  ; 
      oBMP:nHeight() := nVERT, ;
      oBMP:Refresh() ) ;
      COLORS 128, 15977281, 128 ;
      MARKS 49 ;
      UPDATE

REDEFINE GET oGRADVERT VAR nGRADVERT ID 705 PICTURE "999" OF oFld:aDialogs[3] UPDATE ;
VALID ( ( oGRADVERT:Refresh(), oSlider4:Set(nGRADVERT), oSlider4:Refresh(), ;
      nVERT  := 4.9 * nGRADVERT, ;
      oBMP:nHeight() := nVERT, ;
      oBMP:Refresh() ), .T. )

////////////////////////

FUNCTION NEW_SIZE( oBitmap )
LOCAL hDC := oBitmap:GETDC()

// Both doing the same
// ------------------------
oBitmap:SetSize( nHORZ, nVERT )
*PalBmpDraw( hDC, 0, 0, oBitmap:hBitmap, , nVERT, nHORZ )

//aGrad and nDirection are defined !!!
// nMove = 2. Color start-position ( in this sample < 0.50 > centered )
// nVColor = 1. Color
// nBColor = 2. Color
// nDirection : 1 = Horiz., 2 = Vert.
// -------------------------------------
// aGrad := { { nMove, nVColor, nBColor }, ;
//       { nMove, nBColor, nVColor } }

IF nDirection = 1
   GradientFill( hDC,0,0, nVERT, nHORZ, aGrad, .T. )
ELSE
   GradientFill( hDC,0,0, nVERT, nHORZ, aGrad, .F. )
ENDIF

oBitmap:ReleaseDC()

RETURN NIL



Regards
Uwe :lol: