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

x
?
Solved

Resize TImage

Posted on 1998-12-17
5
Medium Priority
?
917 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 40 total points
ID: 1351548
Thanx for the points...  :-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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 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…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

886 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