FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to resize a bitmap ?
Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 04:20 PM

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.

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 07:03 PM

TImage():New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder, oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
cMsg, lUpdate, bWhen, lPixel, bValid, lDesign )

lStretch:=.T.

Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 07:28 PM
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.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 09:04 PM

oIm:=TImage...
oIm:nX:=MySizeX
oIm:nY:=MySizeY

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 09:26 PM

oIm:GoToClipboard()
oCb:=TClipboard():New()
NewBMP:=oCb:GetBitmap()

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 10:20 PM

Toninho,

You have to use Windows API StretchBlt()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 182
Joined: Tue Oct 18, 2005 10:01 AM
How to resize a bitmap ?
Posted: Sat Nov 08, 2008 11:10 PM
Antonio Linares wrote:Toninho,

You have to use Windows API StretchBlt()


Hi Antonio.

Nice hint. Thanks a lot.

Regards,

Toninho.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to resize a bitmap ?
Posted: Tue Jul 14, 2009 08:53 AM
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 - 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 - 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
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to resize a bitmap ?
Posted: Tue Jul 14, 2009 01:33 PM
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.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion