Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Resize TImage

Posted on 1998-12-17
5
Medium Priority
?
910 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

730 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