Page 1 of 1

How to resize a bitmap ?

Posted: Sat Nov 08, 2008 4:20 pm
by toninhofwi
Hi ppl,

How I do to resize a loaded bitmap? For example:

hBmp = LoadBitmap( GetResources(), cBitmap )

hBmp is a 16x16 loaded image and I need resize it to 32x32, without display it, only resize loaded hBmp, something like:

hBmp = BitmapResize( hBmp, 32, 32 )

Thanks in advance and best regards,

Toninho.

Posted: Sat Nov 08, 2008 7:03 pm
by Natter
TImage():New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder, oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
cMsg, lUpdate, bWhen, lPixel, bValid, lDesign )

lStretch:=.T.

Posted: Sat Nov 08, 2008 7:28 pm
by toninhofwi
Natter wrote:TImage():New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder, oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
cMsg, lUpdate, bWhen, lPixel, bValid, lDesign )

lStretch:=.T.
Thanks, but I need it in a different way. I need a new Handle with stretched bitmap.

Regards,

Toninho.

Posted: Sat Nov 08, 2008 9:04 pm
by Natter
oIm:=TImage...
oIm:nX:=MySizeX
oIm:nY:=MySizeY

Posted: Sat Nov 08, 2008 9:26 pm
by Natter
oIm:GoToClipboard()
oCb:=TClipboard():New()
NewBMP:=oCb:GetBitmap()

Posted: Sat Nov 08, 2008 10:20 pm
by Antonio Linares
Toninho,

You have to use Windows API StretchBlt()

Posted: Sat Nov 08, 2008 11:10 pm
by toninhofwi
Antonio Linares wrote:Toninho,

You have to use Windows API StretchBlt()
Hi Antonio.

Nice hint. Thanks a lot.

Regards,

Toninho.

Re: How to resize a bitmap ?

Posted: Tue Jul 14, 2009 8:53 am
by ukoenig
Maybe a possible solution, to use

StretchBlt()

for the new Brush-functions in FWH-9.06, to get the Image-Brush adjusted to the Dialog ???

Image

//--------- IMAGE - BRUSH ------------------------

STATIC FUNCTION DB_IMAGE( oDlg5, hDC, cFile )
LOCAL oBrush, oImg1

// cFile = Image-JPG-Background

DEFINE BRUSH oBrush FILE cFile
SET BRUSH OF oDlg5 TO oBrush
RELEASE BRUSH oBrush

// nWidth := oDlg5:nWidth()
// nHeight := oDlg5:nHeight()
// DEFINE IMAGE oImg1 FILENAME cFile
//oBrush := TBrush():New( , , cFile, , ) ????

RETURN NIL

The old Function with adjusted Image :
Image

//--------- IMAGE - LOGO ------------------------

STATIC FUNCTION DL_IMAGE( oDlg5, hDC, cFile )
LOCAL oImage1
cImage := c_path + "\images\FANTASY7.jpg"
DEFINE IMAGE oImage1 FILENAME cImage
PalBmpDraw( hDC, 0, 0, oImage1:hBitmap, , oDlg5:nWidth(), oDlg5:nHeight(), , .T. )
RETURN NIL

Best Regards
Uwe

Re: How to resize a bitmap ?

Posted: Tue Jul 14, 2009 1:33 pm
by nageswaragunupudi
bmpResized := ResizeBmp( hOldBmp, nNewWidth, nNewHeight )
Maybe a possible solution, to use

StretchBlt()

for the new Brush-functions in FWH-9.06, to get the Image-Brush adjusted to the Dialog ???
The ResizeBmp function internally uses StretchBlt(). So using resizebmp is like using stretchblt().

So, I prefer this approach:
DEFINE BRUSH oTmp FILE cMyImage
oBrush := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, nDlgWidth, nDlgHeight ) )
oTmp:End()

and assign the oBrush to the dialog, This is simple.