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
Solved

Resize and save bitmaps

Posted on 2000-02-29
6
424 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
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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