Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Resize bitmaps
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!

Report this thread to moderator Post Follow-up to this message
Old Post
jill-connie
05-03-05 05:17 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:34 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.