By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,581 Members | 1,966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,581 IT Pros & Developers. It's quick & easy.

Image Transformation

P: n/a
I've been hacking at this for 15 mins, but haven't really got too much
time to spend on it today, so maybe someone here can suggest a quick
fix or suggest if there is a function built into asp.net that I could
look at...

Say I have an image that's 600 x 480 pixels and I want to create a new
image which is cropped from this image to something like 100 x 80
pixels.

The only problem is that the new image must show the full width of the
original image, plus the image should be centered height-wise (i.e.
cropping off the top and bottom of the original image)

Essentially I have 2 rectangles, one for the src image and the other for
the output image.

Using the above example, the output image rectangle is:

(0, 0, 100, 80) - creates an image 100 x 80 pixels, starting at 0,0

and so far I've got the following for the src rectangle:

(0, iSrcY , imgOrig.Width, iSrcHeight)

The values I need here are: iSrcY (the starting point on the y-axis)
iSrcHeight (the height of the source image to take)

these would be calculated using a ratio derived from the size
of the destination image i.e. 100 x 80

Any ideas, or is there an asp.net transformation function built in that
I can use?

Thanks!
--

fiddlewidawiddum
Jan 25 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Do you want to crop or scale? Cropping means chopping off parts of the
image so that it is no longer visible while scaling simply shrinks or
enlarges while keeping the relative dimensions in tacked while keeping the
image whole.

"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
I've been hacking at this for 15 mins, but haven't really got too much
time to spend on it today, so maybe someone here can suggest a quick
fix or suggest if there is a function built into asp.net that I could
look at...

Say I have an image that's 600 x 480 pixels and I want to create a new
image which is cropped from this image to something like 100 x 80
pixels.

The only problem is that the new image must show the full width of the
original image, plus the image should be centered height-wise (i.e.
cropping off the top and bottom of the original image)

Essentially I have 2 rectangles, one for the src image and the other for
the output image.

Using the above example, the output image rectangle is:

(0, 0, 100, 80) - creates an image 100 x 80 pixels, starting at 0,0

and so far I've got the following for the src rectangle:

(0, iSrcY , imgOrig.Width, iSrcHeight)

The values I need here are: iSrcY (the starting point on the y-axis)
iSrcHeight (the height of the source image to take)

these would be calculated using a ratio derived from the size
of the destination image i.e. 100 x 80

Any ideas, or is there an asp.net transformation function built in that
I can use?

Thanks!
--

fiddlewidawiddum

Jan 25 '06 #2

P: n/a
On Wed, 25 Jan 2006 Peter Rilling <pe***@nospam.rilling.net> wrote:
Do you want to crop or scale? Cropping means chopping off parts of the
image so that it is no longer visible while scaling simply shrinks or
enlarges while keeping the relative dimensions in tacked while keeping the
image whole.
Well I want to basically resize the image to the width of the new
rectangle (i.e. 100 pixels), but then to crop this new image around the
centre with a crop height of 80 pixels (or whatever value the target
rectangle is)

The new image must be in the same aspect ratio.

Thanks.

"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
I've been hacking at this for 15 mins, but haven't really got too much
time to spend on it today, so maybe someone here can suggest a quick
fix or suggest if there is a function built into asp.net that I could
look at...

Say I have an image that's 600 x 480 pixels and I want to create a new
image which is cropped from this image to something like 100 x 80
pixels.

The only problem is that the new image must show the full width of the
original image, plus the image should be centered height-wise (i.e.
cropping off the top and bottom of the original image)

Essentially I have 2 rectangles, one for the src image and the other for
the output image.

Using the above example, the output image rectangle is:

(0, 0, 100, 80) - creates an image 100 x 80 pixels, starting at 0,0

and so far I've got the following for the src rectangle:

(0, iSrcY , imgOrig.Width, iSrcHeight)

The values I need here are: iSrcY (the starting point on the y-axis)
iSrcHeight (the height of the source image to take)

these would be calculated using a ratio derived from the size
of the destination image i.e. 100 x 80

Any ideas, or is there an asp.net transformation function built in that
I can use?

Thanks!
--

fiddlewidawiddum


--

fiddlewidawiddum
Jan 25 '06 #3

P: n/a
On Wed, 25 Jan 2006 Stimp <re*@spumco.com> wrote:
On Wed, 25 Jan 2006 Peter Rilling <pe***@nospam.rilling.net> wrote:
Do you want to crop or scale? Cropping means chopping off parts of the
image so that it is no longer visible while scaling simply shrinks or
enlarges while keeping the relative dimensions in tacked while keeping the
image whole.


Well I want to basically resize the image to the width of the new
rectangle (i.e. 100 pixels), but then to crop this new image around the
centre with a crop height of 80 pixels (or whatever value the target
rectangle is)

The new image must be in the same aspect ratio.


I've just noticed that my example was a bit odd since the source and
destination rectangles are the same ratio (doh!)

Ok a better example would be:

Source rectangle: 363px x 251px

and the destination rectangle is: 212px x 57px

--

fiddlewidawiddum
Jan 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.