Solved

Resize TImage

Posted on 1998-12-17
5
898 Views
Last Modified: 2007-12-19
Hi,
how do I convert an resized Image to an Image, which normal size is the resized size ?
e.g. my image is 32x32 I resize it to 32x64 (by stretching it) . Now I need to convert the
image so that 32x64 is the normal size (When I load the image with autosize=true and
stretched=false the image must has the size 32x64. I must do that without using the hdd.
0
Comment
Question by:ItsMe
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1351544
I have not test it, but try this:

procedure StretchImage(oldImg,newImg: TImage);
begin
  newImg.width:=32; newImg.height:=64;
  newImg.picture.bitmap.width:=32; newImg.picture.bitmap.height:=64;
  newImg.picture.bitmap.canvas.StretchDraw(Rect(0,0,32,64),oldImg);
end;

Regards... Madshi.
0
 

Author Comment

by:ItsMe
ID: 1351545
Ok, I think that'll work. I'm asking the user for the new bitmap height and width. Now the original
bitmap should be changed to the new size. I'm only using 1 Image component. And I can't use
stretch because it doesn't work with my program (I'm using OnMouseMove, CanvasMoveTo etc.)
and when I stretch it "normal" my rectangle end position doesn't match with mouse position. Perhaps
you could send me a source code ? (StretchDraw wants a TGraphic not an image ???). You can
compare my program with Borland's "Graphex" example program but my program must be able to change
the image size.

Regards
ItsMe
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1351546
Ok, another try:

procedure StretchImage(var img: TImage; newWidth,newHeight: integer);
var bmp : TBitmap;
begin
  bmp:=TBitmap.Create;
  try
    bmp.width:=newWidth; bmp.height:=newHeight;
    bmp.canvas.StretchDraw(Rect(0,0,32,64),img.picture.graphic);
    img.picture.SetBounds(img.left,img.top,newWidth,newHeight);
    img.picture.bitmap.Assign(bmp);
  finally bmp.free end;
end;

Regards... Madshi.
0
 

Author Comment

by:ItsMe
ID: 1351547
Dear Madshi, now my program works. Thank you. Please send a comment as answer, so that I can
accept it.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 10 total points
ID: 1351548
Thanx for the points...  :-)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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