Some code I have had laying around here for a while; This should help your
problem as well.
public System.Drawing. Image ResizeImage(Sys tem.Drawing.Ima ge
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.W idth, poSize.Height,
oImageOriginal. PixelFormat);
System.Drawing. Graphics oGraphic =
Graphics.FromIm age(oResizedIma ge);
oGraphic.Compos itingQuality =
System.Drawing. Drawing2D.Compo sitingQuality.H ighQuality ;
oGraphic.Smooth ingMode =
System.Drawing. Drawing2D.Smoot hingMode.HighQu ality ;
oGraphic.Interp olationMode =
System.Drawing. Drawing2D.Inter polationMode.Hi ghQualityBicubi c ;
Rectangle oRectangle = new Rectangle(0, 0,
poSize.Width, poSize.Height);
oGraphic.DrawIm age(oImageOrigi nal, oRectangle);
oGraphic.Dispos e() ;
oImageOriginal. Dispose();
return oResizedImage;
}
Cheers,
Greg Young
MVP - C#
"Neeraj" <kn*******@gmai l.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
hi
i am working on dicom image.this is code which gives exception on
"System.Drawing .Image imgInFile = System.Drawing. Image.FromStrea m(new
System.IO.Memor yStream(destPix els ) "
.The exception is "System.Argumen tException: 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.Colle ct();
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("PIXDA TA == NULL");
System.Drawing. Image imgInFile =
System.Drawing. Image.FromStrea m(new System.IO.Memor yStream(destPix els )
return imgInFile;
}