Solved

Resize and save bitmaps

Posted on 2000-02-29
6
423 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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