Some code I have had laying around here for a while; This should help your
problem as well.
public System.Drawing.Image ResizeImage(System.Drawing.Image
poImage, System.Drawing.Size poSize) {
//Detach image from its source
System.Drawing.Image oImageOriginal =
(System.Drawing.Image)poImage.Clone();
//Resize new image
System.Drawing.Image oResizedImage = new
System.Drawing.Bitmap(poSize.Width, poSize.Height,
oImageOriginal.PixelFormat);
System.Drawing.Graphics oGraphic =
Graphics.FromImage(oResizedImage);
oGraphic.CompositingQuality =
System.Drawing.Drawing2D.CompositingQuality.HighQu ality ;
oGraphic.SmoothingMode =
System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
oGraphic.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQua lityBicubic ;
Rectangle oRectangle = new Rectangle(0, 0,
poSize.Width, poSize.Height);
oGraphic.DrawImage(oImageOriginal, oRectangle);
oGraphic.Dispose() ;
oImageOriginal.Dispose();
return oResizedImage;
}
Cheers,
Greg Young
MVP - C#
"Neeraj" <kn*******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
hi
i am working on dicom image.this is code which gives exception on
"System.Drawing.Image imgInFile = System.Drawing.Image.FromStream(new
System.IO.MemoryStream(destPixels ) "
.The exception is "System.ArgumentException: Parameter is not valid."
could any body help me
i am waiting for help
regards,
Neeraj Kumar
protected internal virtual System.Drawing.Image scaleImage()
{
int scaledWidth = w / 2;
int scaledHeight = h / 2;
int index = 0;
int value_Renamed = 0;
byte[] destPixels = null;
this.pixData = dHR.data;
System.GC.Collect();
destPixels = new byte[scaledWidth * scaledHeight];
for (int i = 0; i < h; i += 2)
{
for (int j = 0; j < w; j += 2)
{
destPixels[index++] = (byte)pixData[(i * w) + j];
}
}
pixData = null;
Tools.gc("PIXDATA == NULL");
System.Drawing.Image imgInFile =
System.Drawing.Image.FromStream(new System.IO.MemoryStream(destPixels )
return imgInFile;
}