Code Comments
Programming Forum and web based access to our favorite programming groups.I want to resize a bitmap, but that seems to be easier said than done. My original bitmap has pixel format 8bpp indexed. I would think that creating a new bitmap with the constructor Bitmap compressedImage = newBitmap( Image original, original.Width/2, orig inal.Height/2 ) would do the trick, but it changes the format to 32 bpp Argb, even though it says in my book that "the new bitmap inherits the pixel format of the existing bitmap". So, I thought I could clone my compressedImage: Bitmap cloneCompressedImage = compressedImage.Clone( new Rectangle( 0,0,co mpressedImage.Width,compressedImage.Height), System.Drawing.Imaging.PixelFormat.Format8bppIndexed ) ; but it raises an OutOfMemory exception, no matter which values I try for wid th and height. Just for fun I tried to clone my original image: Bitmap cloneOriginalImage = original.Clone( new Rectangle( 0,0,original.Wi dth,original.Height), System.Drawing.Imaging.PixelFormat.Format8bppIndexed ) ; It works fine, but if I try to set the correct dimensions I get only a porti on of the original(of course). I've also tried using Graphics gr = Graphics.FromImage( original ); but got an exeption saying "A Graphics object cannot be created from an imag e that has an indexed pixel format" If anyone has an idea on how to maintain the pixel format, or maybe has anot her way of doing this, - please let me know!
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.