Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resize and save bitmaps

Posted on 2000-02-29
6
Medium Priority
?
435 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 150 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview

772 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