Solved

Resize TImage

Posted on 1998-12-17
5
895 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanx for the points...  :-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

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

19 Experts available now in Live!

Get 1:1 Help Now