Solved

Resize and save bitmaps

Posted on 2000-02-29
6
425 Views
Last Modified: 2010-05-18
For example, a 640x480 bitmap is loaded into a TImage, how can I save the picture into a new bitmap file of a dimension of 320x240 pixels?  Example code expected.
(D2)
0
Comment
Question by:yingkit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:wmckie
ID: 2567972
I can't answer your question but take a look at Earl Glynn's site:

http://www.efg2.com/lab/

He has a large number of examples of manipulating images and links.

Good luck - Walter McKie
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 2567988
hi yingkit,

you can use the stretchdraw-method like

DestBitmap := TBitmap.Create;
DestBitmap.Width := 320;
DestBitmap.Height := 240;
DestBitmap.Canvas.StretchDraw(Rect(0,0,320,240),SourceBitmap);
DestBitmap.SaveToFile('AFileName.bmp');

meikl
0
 

Expert Comment

by:Vovbager
ID: 2567990
hi vin
try to use this code

var NewBitmap: TBitmap;
begin
  NewBitmap:=TBitmap.Create;
  NewBitmap.Width:=320;
  NewBitmap.Height:=240;

  StretchBlt(NewBitmap.Canvas.Handle, 0,0,320,240, Image1.Canvas.Handle,0,0,640,480,SRCCOPY);
  NewBitmap.SaveToFile(FileName);
  NewBitmap.Free;
end;

end;

vov
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:yingkit
ID: 2568026
Hi vov,
Only a 320x240 *blank* bitmap is generated.  Is there something wrong with the code?
0
 

Expert Comment

by:Vovbager
ID: 2568085
you must load source bitmap into the Image1
0
 

Author Comment

by:yingkit
ID: 2568094
Although meiki submits as comment, the code works fine.
Also, meiki submitted first.
Thank you all !!
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question