Board index » cppbuilder » TImage with aspect ratio...how to resize image itself?

TImage with aspect ratio...how to resize image itself?


2004-12-05 07:41:06 PM
cppbuilder17
Hi all. I need to make a TImage with aspect ratio feature.
I just can't find an object/property/method/anything that can size my image
as I wish.
Any hints?
thanks, bye
 
 

Re:TImage with aspect ratio...how to resize image itself?

Fix_Metal,
I suspect this isn't exactly what you want; however, the way you accomplish
this task with TImage is by setting the Stretch property to true and then
resize the Width and Height appropriately. Now, I'm not sure if you know
how to adjust for aspect ratio but here is a quick example:
static const xAspect = 16;
static const yAspect = 9;
static const height_of_area = 200;
// Assume that the height should remain constant
Image1->Stretch = true;
Image1->Width = height_of_area * xAspect / yAspect;
Image1->Height = height_of_area;
The above example assumes a video mode with a square aspect ratio (square
pixels).
HTH,
- Clayton
 

Re:TImage with aspect ratio...how to resize image itself?

thx dude. while I was searching about this problem, I finally did it by
myself with a method that is just like your...
thanks anyway :)
"Clayton Arends" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote
Fix_Metal,

I suspect this isn't exactly what you want; however, the way you
accomplish
this task with TImage is by setting the Stretch property to true and then
resize the Width and Height appropriately. Now, I'm not sure if you know
how to adjust for aspect ratio but here is a quick example:

static const xAspect = 16;
static const yAspect = 9;
static const height_of_area = 200;

// Assume that the height should remain constant
Image1->Stretch = true;
Image1->Width = height_of_area * xAspect / yAspect;
Image1->Height = height_of_area;

The above example assumes a video mode with a square aspect ratio (square
pixels).

HTH,
- Clayton


 

{smallsort}

Re:TImage with aspect ratio...how to resize image itself?

Ok now I'm ok with the ratio. Anyway i'd like to know how to make a single
function of that piece of "resize code", since it'd be more useful to
re-call it anytime i want anywhere i want, instead of copy-paste for every
single event :)
thanks in advance,
cheers