You don't need to use Bitmap pic = new Bitmap(Project1.Properties.Resources.Picture);
Project1.Properties.Resources.Picture should be Image type. Say if you want to display it in a picturebox, simply write:
picturebox1.Image = Project1.Properties.Resources.Picture;
and the resolution will remain unchanged as 300dpi.
If you just store the path of the image in your resource file, first use:
Image pic = Image.FromFile(Project1.Properties.Resources.Picture);
to load the image, then write something like this:
Code:
byte[] bytes = Encoding.UTF8.GetBytes("300/1");
PropertyItem item = pic.GetPropertyItem(0x011a);//X-resolution tag defined in EXIF standard
item.Value = bytes;
pic.SetPropertyItem(item);
item = pic.GetPropertyItem(0x011b);//Y-resolution tag defined in EXIF standard
item.Value = bytes;
pic.SetPropertyItem(item);
If you use Bitmap to load the image, you may have to use SetResolution method to change the resolution.
Bookmarks