In my Web application, iam displaying images. I want to convert an image of type(BMP,TIF etc.,) to JPG and highlight(Drawing transparent Rectangles on the Image )the portion of the image and display it on web page. How can i acheive this with asp.net &
C#???
It didn't helped me.. Iam able to convert the TIFF images to PNG/JPG. Now when i try to draw rectangles, i mean if i instantiate the
Graphics class, it is throwing "a graphics object cannot be created from an image that has an indexed pixel format" exception?
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbnailGraph.DrawImage(image, imageRectangle);
Color color = Color.FromArgb(50, 255, 255, 255);
SolidBrush brush = new SolidBrush(color);
Point atPoint = new Point(10, 10);
Pen pen=new Pen(brush);
thumbnailGraph.FillRectangle(brush, imageRectangle);
Star
14075 Points
3271 Posts
Drawing Rectangles on Image
Apr 02, 2010 02:03 AM|roopeshreddy|LINK
Hi,
In my Web application, iam displaying images. I want to convert an image of type(BMP,TIF etc.,) to JPG and highlight(Drawing transparent Rectangles on the Image )the portion of the image and display it on web page. How can i acheive this with asp.net & C#???
Thanks & Regards
Roopesh Reddy C
Roopesh Reddy C
Roopesh's Space
Contributor
5449 Points
1300 Posts
Re: Drawing Rectangles on Image
Apr 02, 2010 03:36 AM|gopalanmani|LINK
Hi,
check the following urls for image operations in asp.net,
http://www.codeproject.com/KB/web-image/pnguploader.aspx
http://www.4guysfromrolla.com/articles/012203-1.aspx
http://nathanaeljones.com/products/asp-net-image-resizer/
http://forums.asp.net/p/1433920/3229333.aspx
Gopalan Mani
My Tech blog
Star
14075 Points
3271 Posts
Re: Drawing Rectangles on Image
Apr 02, 2010 07:44 AM|roopeshreddy|LINK
Hi,
It didn't helped me.. Iam able to convert the TIFF images to PNG/JPG. Now when i try to draw rectangles, i mean if i instantiate the Graphics class, it is throwing "a graphics object cannot be created from an image that has an indexed pixel format" exception?
Roopesh Reddy C
Roopesh's Space
Contributor
4392 Points
934 Posts
Re: Drawing Rectangles on Image
Apr 05, 2010 02:33 AM|Vipindas|LINK
using System.Drawing;
using System.Drawing.Drawing2D;
public static void ResizeStream(int imageSize, Stream filePath, string outputPath)
{
var image = Image.FromStream(filePath);
int thumbnailSize = imageSize;
int newWidth, newHeight;
if (image.Width > image.Height)
{
newWidth = thumbnailSize;
newHeight = image.Height * thumbnailSize / image.Width;
}
else
{
newWidth = image.Width * thumbnailSize / image.Height;
newHeight = thumbnailSize;
}
var thumbnailBitmap = new Bitmap(newWidth, newHeight);
var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbnailGraph.DrawImage(image, imageRectangle);
Color color = Color.FromArgb(50, 255, 255, 255);
SolidBrush brush = new SolidBrush(color);
Point atPoint = new Point(10, 10);
Pen pen=new Pen(brush);
thumbnailGraph.FillRectangle(brush, imageRectangle);
thumbnailBitmap.Save(outputPath);
thumbnailGraph.Dispose();
thumbnailBitmap.Dispose();
image.Dispose();
}
Star
14075 Points
3271 Posts
Re: Drawing Rectangles on Image
Apr 05, 2010 10:35 AM|roopeshreddy|LINK
Hi,
Thanks for ur help. I had solved my problem using GDI+ classes in .NET.
I used Bitmap Class to create a bitmap and Graphics class to draw the shapes on the images
Thanks & Regards
Roopesh Reddy C
Roopesh Reddy C
Roopesh's Space
None
0 Points
32 Posts
Re: Drawing Rectangles on Image
May 28, 2010 11:18 AM|bhupendra TG|LINK
Hi
How I can capture a portion(rectangle) by cordinates or dimensions from an image or from web page?
Please suggest me the proper way.
Thanks
Bhupendra
Member
3 Points
21 Posts
Re: Drawing Rectangles on Image
Jun 24, 2010 09:27 AM|mail2rit|LINK
Hi Bhupendra,
Were you able to sort out the problem.
I also need something like that.
Regards,
Ritesh...
None
0 Points
3 Posts
Re: Drawing Rectangles on Image
Feb 28, 2013 05:11 AM|RSMakadia|LINK
Hello,
Can any one help me to draw shapes on image with Mouse movements ?
None
0 Points
3 Posts
Re: Drawing Rectangles on Image
Feb 28, 2013 05:13 AM|RSMakadia|LINK
Hello,
Did you able to make shapes on images ? I want to achive same kind of thing in my web application. Can you help me ?