.Net Bitmap class constructor (int, int) and (int, int, PixelFormat) throws ArgumentException on perfectly good arguments

后端 未结 3 402
醉酒成梦
醉酒成梦 2020-12-10 15:27

I have some code that does something like this (Irrelevant bits snipped):

void foo(Bitmap bmp1, Bitmap bmp2)
{
    Bitmap bmp3;
    if(something)
        bmp         


        
3条回答
  •  Happy的楠姐
    2020-12-10 16:02

    Anyone have any ideas?

    Wrap the call that is throwing ArgumentException with a try-catch(Exception ex) and step into the exception block to see the raw exception. It should give you more detail, like which argument is supposedly invalid.

    try
    {
        bmp3 = new Bitmap(bmp1.Width, bmp1.Height + bmp2.Height);
    }
    catch (Exception ex)
    {   
        throw;  // breakpoint here, examine "ex"
    }
    

提交回复
热议问题