Solved

Resize and save bitmaps

Posted on 2000-02-29
6
420 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

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

Expert Comment

by:Vovbager
Comment Utility
you must load source bitmap into the Image1
0
 

Author Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now