Click here to Skip to main content
15,893,190 members
Home / Discussions / C#
   

C#

 
GeneralRe: OnPaint ClipRectangle is whole control when resizing Pin
Rob Philpott13-Feb-08 0:41
Rob Philpott13-Feb-08 0:41 
GeneralRe: OnPaint ClipRectangle is whole control when resizing Pin
Mircea Puiu13-Feb-08 0:52
Mircea Puiu13-Feb-08 0:52 
QuestionVLC Pin
Smithakrishnan12-Feb-08 21:17
Smithakrishnan12-Feb-08 21:17 
GeneralCNG Components for windows XP Pin
Abhijit Jana12-Feb-08 21:15
professionalAbhijit Jana12-Feb-08 21:15 
Generalconvert 24bppRgb to 8bppIndexed in c#. Pin
Abdul Rahman Hamidy12-Feb-08 20:49
Abdul Rahman Hamidy12-Feb-08 20:49 
GeneralRe: convert 24bppRgb to 8bppIndexed in c#. Pin
Ed.Poore12-Feb-08 21:45
Ed.Poore12-Feb-08 21:45 
GeneralRe: convert 24bppRgb to 8bppIndexed in c#. Pin
Abdul Rahman Hamidy12-Feb-08 22:04
Abdul Rahman Hamidy12-Feb-08 22:04 
GeneralRe: convert 24bppRgb to 8bppIndexed in c#. Pin
Martin#12-Feb-08 22:00
Martin#12-Feb-08 22:00 
Hello,

As "Ed.Poore" just said, you really should use Dispose or a using-block to free your GDI objects!
But this is not causing the exception.
It's also not that you are Out of bounds, which could also lead to this exception (seen in the msdn docu[^])

I think that the underlying problem is, that it's not possible to create an Graphics object from an bitmap with this PixelFormat.
Can be seen here:
using(Bitmap img = new Bitmap(@"c:\sky.bmp"))
using(Bitmap bm = Clone(img, PixelFormat.Format8bppIndexed))
{
   //???
}
 
public static Bitmap Clone( Bitmap source, PixelFormat format )
{
    int width = source.Width;
    int height = source.Height;
 
    // create new image with desired pixel format
    Bitmap bitmap = new Bitmap( width, height, format );
 
    // draw source image on the new one using Graphics
    using(Graphics g = Graphics.FromImage( bitmap ))    //Throws an exception here
    {
        g.DrawImage( source, 0, 0, width, height );
    }
 
    return bitmap;
}

I'm sure the articles from "Christian Graus", about "Image Processing" will help you.
Look here![^]

All the best,

Martin

GeneralRe: convert 24bppRgb to 8bppIndexed in c#. Pin
Abdul Rahman Hamidy12-Feb-08 22:18
Abdul Rahman Hamidy12-Feb-08 22:18 
GeneralRe: convert 24bppRgb to 8bppIndexed in c#. Pin
Martin#12-Feb-08 22:20
Martin#12-Feb-08 22:20 
GeneralOT Pin
Vikram A Punathambekar13-Feb-08 1:30
Vikram A Punathambekar13-Feb-08 1:30 
GeneralRe: OT Pin
Martin#13-Feb-08 4:24
Martin#13-Feb-08 4:24 
QuestionHow to get German charators Pin
Jamman12-Feb-08 20:42
Jamman12-Feb-08 20:42 
AnswerRe: How to get German charators Pin
Tony Richards12-Feb-08 22:07
Tony Richards12-Feb-08 22:07 
AnswerRe: How to get German charators Pin
Guffa12-Feb-08 22:14
Guffa12-Feb-08 22:14 
AnswerRe: How to get German charators Pin
Joachim Kerschbaumer12-Feb-08 22:15
Joachim Kerschbaumer12-Feb-08 22:15 
GeneralRe: How to get German charators Pin
Jamman12-Feb-08 22:29
Jamman12-Feb-08 22:29 
GeneralRe: How to get German charators Pin
Guffa13-Feb-08 0:03
Guffa13-Feb-08 0:03 
Generalnot working Pin
Krishna Varadharajan12-Feb-08 19:37
Krishna Varadharajan12-Feb-08 19:37 
GeneralRe: not working Pin
Christian Graus12-Feb-08 19:41
protectorChristian Graus12-Feb-08 19:41 
GeneralRe: not working Pin
Krishna Varadharajan12-Feb-08 20:23
Krishna Varadharajan12-Feb-08 20:23 
GeneralChanging extension of assembly [modified] Pin
Imtiaz Murtaza12-Feb-08 15:43
Imtiaz Murtaza12-Feb-08 15:43 
GeneralRe: Changing extension of assembly Pin
Not Active12-Feb-08 16:03
mentorNot Active12-Feb-08 16:03 
GeneralCustom Behaviour. Pin
bsaksida12-Feb-08 11:22
bsaksida12-Feb-08 11:22 
GeneralSystem.Diagnostics.Process hide process's console window Pin
aei_totten12-Feb-08 10:57
aei_totten12-Feb-08 10:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.