GDI+ using setResolution always results in resolution of 96x96



I am using a Bitmap object to modify JPEG images of variing
resolutions.
We'd decided (albeit arbitrarily) to refactor the images at a
resolution of 200x200, and then rescale the images' dimensions.

The process seems to work, but the images' resoluion is always 96x96,
not 200x200.
I've found no documentation stating any specific, valid resolutions for
a Bitmap object, so it's vexing me that it is not what I specified it
to be.
Any help either explaining why this is so and/or how to fix it would be
greatly appreciated.

Thanks in Advance.

Relevant Bits of the Code (possibly some overkill in it, as I've been
trying differeing methods to get it to work):

System.Collections.Hashtable imageOutputFormatsTable = new
System.Collections.Hashtable();
imageOutputFormatsTable.Add(System.Drawing.Imaging.ImageFormat.Gif.Guid,System.Drawing.Imaging.ImageFormat.Gif);
imageOutputFormatsTable.Add(System.Drawing.Imaging.ImageFormat.Jpeg.Guid,System.Drawing.Imaging.ImageFormat.Jpeg);
imageOutputFormatsTable.Add(System.Drawing.Imaging.ImageFormat.Bmp.Guid,System.Drawing.Imaging.ImageFormat.Bmp);
imageOutputFormatsTable.Add(System.Drawing.Imaging.ImageFormat.Tiff.Guid,System.Drawing.Imaging.ImageFormat.Tiff);
imageOutputFormatsTable.Add(System.Drawing.Imaging.ImageFormat.Png.Guid,System.Drawing.Imaging.ImageFormat.Png);


Bitmap outputImage = new Bitmap(newWidth, newHeight);
outputImage.SetResolution(newHRes, newVRes);
Graphics g = Graphics.FromImage(outputImage);
g.DrawImage(origBitmap, new Rectangle(0, 0,
outputImage.Width, outputImage.Height)
, 0, 0, origBitmap.Width, origBitmap.Height,
GraphicsUnit.Pixel);
g.Dispose();
ImageFormat outputFormat =
(ImageFormat)imageOutputFormatsTable[origBitmap.RawFormat.Guid];

using (MemoryStream ms = new MemoryStream())
{
ImageCodecInfo outputCodec=null;
ImageCodecInfo[] codecs =
ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType.Contains("jpeg"))
{
outputCodec = codec;
}
}

EncoderParameters outputCodecParams = new
EncoderParameters(1);

System.Drawing.Imaging.Encoder qualityEncoder =
System.Drawing.Imaging.Encoder.Quality;
EncoderParameter encoderParam0 = new
EncoderParameter(qualityEncoder, 85L);
outputCodecParams.Param[0] = encoderParam0;
if (outputCodec != null)
{
outputImage.Save(ms, outputCodec,
outputCodecParams);
//outputImage.Save(ms, outputFormat);
outputImage.Dispose();
origBitmap.Dispose();
_image = Image.FromStream(ms, true);
return _image;
}
}

.



Relevant Pages

  • GDI+ SetResolution always results in 96x96
    ... I am using a Bitmap object to modify JPEG images of variing ... I've found no documentation stating any specific, valid resolutions for ... ImageFormat outputFormat ...
    (microsoft.public.dotnet.languages.csharp)
  • GDI+ using setResolution always results in resolution of 96x96
    ... I am using a Bitmap object to modify JPEG images of variing ... I've found no documentation stating any specific, valid resolutions for ... ImageFormat outputFormat ...
    (microsoft.public.dotnet.general)
  • GDI+ Bitmap.SetResolution always results in 96x96
    ... I am using a Bitmap object to modify JPEG images of variing ... I've found no documentation stating any specific, valid resolutions for ... ImageFormat outputFormat ...
    (microsoft.public.dotnet.csharp.general)
  • RE: Memory problem with images
    ... > I'm developing a ppc application that receives images from a url and ... > The problem is that at each ticking a new bitmap object is created ... > I'd like creating a bitmap object once and using a '.FromStream' method ... but the Image.FromStream static method is not ...
    (microsoft.public.dotnet.framework.compactframework)
  • High resolution images in VB.NET
    ... parts of the input files. ... so basicly i load the input files in memory so the program will be as fast ... the images i load is about 8000x7500 pixels tho i would like to load even ... larger files but the bitmap object seems to have the limit i spoke of. ...
    (microsoft.public.dotnet.languages.vb)

Quantcast