How to resize a bitmap ?

How to resize a bitmap ?

Postby toninhofwi » Sat Nov 08, 2008 4: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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Postby Natter » Sat Nov 08, 2008 7: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.
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Postby toninhofwi » Sat Nov 08, 2008 7: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.
toninhofwi
 
Posts: 172
Joined: Tue Oct 18, 2005 10:01 am

Postby Natter » Sat Nov 08, 2008 9:04 pm

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

Postby Natter » Sat Nov 08, 2008 9:26 pm

oIm:GoToClipboard()
oCb:=TClipboard():New()
NewBMP:=oCb:GetBitmap()
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Postby Antonio Linares » Sat Nov 08, 2008 10:20 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Re: How to resize a bitmap ?

Postby ukoenig » Tue Jul 14, 2009 8: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

//--------- 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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to resize a bitmap ?

Postby nageswaragunupudi » Tue Jul 14, 2009 1: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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests