TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paul Turner
NA
6
3.6k
Crop image without pixel colour change
Oct 14 2011 1:09 PM
i have been using the following code to crop images:
public static System.Drawing.Image cropImage(System.Drawing.Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
return (System.Drawing.Image)(bmpCrop);
}
which works fine except that the pixels RGB colour values change when you compare the cropped image to the original. i need them to stay exactly the same. it seems that by default the new image created has a smaller colour palette, and i have found ways to get better results, but not a way which just gives the same colour palette and the same RGB values for the pixels in the new cropped image which you create. it seems crazy to me that you can't do this.
one way around this would be to avoid creating a new image but instead to actually crop the original image but again i cant find anything on this.
is there anyone really clever that can help me here?
Reply
Answers (
6
)
SqlDateTime overflow
Execute an event when a specific button inside a gridview is clicked