473,289 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Image Transformation

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
3 1563
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Weston C | last post by:
I'm new to the GD/Image functions with PHP, and I'm trying to use them to manipulate jpeg images that I've stored in a MySQL database (specifically, creating thumbnails). The thing I can't tell...
8
by: Chris Dewin | last post by:
Hi. I run a website for my band, and the other guys want an image gallery. I'm thinking it would be nice and easy, if we could just upload a jpg into a dir called "gallery/". When the client...
2
by: Larry Marburger | last post by:
I've built and XSLT that is used to generate a simple TreeView-type, web-based control (ASP.NET / C#). When the tree is fully transformed (client-side, JavaScript transformation), there are about...
0
by: monfu | last post by:
Dear all I have the following code:- System.Drawing.Image src_image = System.Drawing.Image.FromStream(imgStream); Bitmap bitmap = new Bitmap(image_width, image_height,...
3
by: Douglas Douglas | last post by:
Hi everybody. I have a paper form that I scan into an image. My user fills some circles in this paper form using black ink. Every form has ten rows with five circles each and the user fills only...
3
by: Keith G Hicks | last post by:
In MS Access image controls there's a property setting for "Size Mode" --> Clip, Zoom or Stretch. I don't see any similar property in an asp image control. When I have an image on a page, it seems...
0
by: frankkirchner | last post by:
There has to be a way to get an image into the XSLT transormation process so that it shows up on a Formatted Excel Spreadsheet. When saving an Excel spreadsheet to XML format - you lose the image...
6
by: PenguinPig | last post by:
Dear All Experts I would like to know how to convert a HTML into Image using C#. Or allow me contains HTML code (parsed) in Image? I also tried this way but it just display the character "<" &...
5
by: Michael | last post by:
Hello all, how could I rotate a server side image in asp.net and show it in web page? Thanks.
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.