>> [...]
>>> You should be, just as the docs for GetThumbnailImage() indicate, be
[quoted text clipped - 9 lines]
>>> takes
>>> an original image and a new size,
Isn't that the same thing as the GetThumbnailImage() where you take the
Image and GetThumbnailImage resizes it to the size you pass:
MemoryStream ms = new MemoryStream(myByteArray, 0, myByteArray.Length);
ms.Write(myByteArray, 0, myByteArray.Length);
System.Drawing.Image oImage = Image.FromStream(ms, true);
oImage = oImage.GetThumbnailImage(imageWidth, imageHeight, null,
IntPtr.Zero);
as opposed to your GetImageResize:
MemoryStream ms = new MemoryStream(myByteArray, 0, myByteArray.Length);
ms.Write(myByteArray, 0, myByteArray.Length);
System.Drawing.Image oImage = Image.FromStream(ms, true);
oImage = GetImageResize(Image image, imageWidth, imageHeight;
I would assume (though I am probably wrong here) that the Bitmap resize is
doing the same thing as the GetThumbnailImage.
>> Isn't that what I am doing?
>
[quoted text clipped - 6 lines]
> return new Bitmap(image, cxWidth, cyHeight);
> }
But a BitMap takes more space that say a jpeg.
What we are trying to do is take a 1 meg jpeg file and compress (may be the
wrong word here) it a to a newer size based on the width. Using
GetThumbnailImage we get a new jpeg to about 50k.
>>> or if you need higher-quality scaling, you can create a new Bitmap
>>> instance of the correct size
[quoted text clipped - 19 lines]
> return imageRet;
> }
I assume you meant:
Image imageRet = new Bitmap(image,cxWidth, cyHeight);
> Adding, of course, whatever specific drawing settings you want in
> order to control the quality of the redrawn image.
[quoted text clipped - 11 lines]
> Well, according to the docs for the Bitmap class, .NET/GDI+ doesn't
> support PCX. It lists BMP, GIF, EXIG, JPG, PNG and TIFF. No PCX.
And you explained that the Image class is really an abstract class and I
assume is derived from the Bitmap class which would explain why it doesn't
work.
Thanks,
Tom
> Pete
Peter Duniho - 25 Mar 2008 21:17 GMT
> [...]
> I would assume (though I am probably wrong here) that the Bitmap resize
> is
> doing the same thing as the GetThumbnailImage.
I'm not sure what to say. You acknowledge you made an assumption _and_
that you're probably wrong, and yet you are still wondering why my code is
different from yours?
The method GetThumbnailImage() has a very specific purpose: to retrieve a
thumbnail image. Some images come with thumbnails already created, and if
they do, that's the image that will be used. You can optionally request
that the thumbnail be returned as a specific size, but when you do so, you
are asking for the _thumbnail_ to be resized, not the original image.
If an image does not yet have a thumbnail, then yes...the original is used
instead. But otherwise, it's not.
The code I provided resizes the original image _always_. If you don't
want to accidently resize the thumbnail instead of the original image,
don't use GetThumbnailImage().
> But a BitMap takes more space that say a jpeg.
Not in memory it doesn't. JPEG is a format used mainly for files. In
.NET, when you read a JPEG file, you get an uncompressed Bitmap in memory.
> What we are trying to do is take a 1 meg jpeg file and compress (may be
> the
> wrong word here) it a to a newer size based on the width. Using
> GetThumbnailImage we get a new jpeg to about 50k.
And so too can you with the Bitmap. Just save the Bitmap instance in the
JPEG format.
> [...]
> I assume you meant:
>
> Image imageRet = new Bitmap(image,cxWidth, cyHeight);
That's an incorrect assumption.
>> Well, according to the docs for the Bitmap class, .NET/GDI+ doesn't
>> support PCX. It lists BMP, GIF, EXIG, JPG, PNG and TIFF. No PCX.
[quoted text clipped - 3 lines]
> doesn't
> work.
No. Bitmap inherits Image, not the other way around. And in either case
that has nothing to do with why a PCX file isn't supported.
Pete