How to resize a bitmap ?

Post Reply
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

How to resize a bitmap ?

Post 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.
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Post 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.
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Post 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.
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Post by Natter »

oIm:=TImage...
oIm:nX:=MySizeX
oIm:nY:=MySizeY
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Post by Natter »

oIm:GoToClipboard()
oCb:=TClipboard():New()
NewBMP:=oCb:GetBitmap()
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Toninho,

You have to use Windows API StretchBlt()
Last edited by Antonio Linares on Sun Nov 09, 2008 5:44 am, edited 1 time in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
toninhofwi
Posts: 161
Joined: Tue Oct 18, 2005 10:01 am

Post by toninhofwi »

Antonio Linares wrote:Toninho,

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

Nice hint. Thanks a lot.

Regards,

Toninho.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to resize a bitmap ?

Post 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
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.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: How to resize a bitmap ?

Post 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.
Regards

G. N. Rao.
Hyderabad, India
Post Reply