CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    5

    Exclamation GDI+ Bitmap size limitation?

    It seems that bitmaps of the GDI+ Bitmap class are limited to a size of 32767 pixels in either direction (width, height).
    I use Visual C++ 6.0 with latest patch, plus Platform SDK.

    This limit is not documented, and I have not found anything on the topic on the net; all I did find was that GDI+ is supposed to overcome any previous short-int limitations (e.g., GDI display surface).

    In the attached demo application (see CTest_bmpView::OnDraw), if 32768 or a larger value is used for the width or height of the GDI+ bitmap, although creation of the bitmap and operations on it (e.g., FillRectangle) are successful, display (using Graphics::DrawImage) or saving (Bitmap::Save) fail, with status code InvalidParameter and Win32Error, respectively.
    Additional error information obtained using ::GetLastError is useless ("Operation Successful").

    Has anyone encountered this problem, or even better, knows how to overcome it? Would also appreciate the odd report of reproducibility.
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2006
    Posts
    5

    Re: GDI+ Bitmap size limitation?

    I'd also be interested whether anyone can reproduce this problem with a newer environment, e.g., DevStudio 200X.

    Thanks in advance!

  3. #3
    Join Date
    Dec 2006
    Posts
    5

    Re: GDI+ Bitmap size limitation?

    Anyone?

  4. #4
    Join Date
    Feb 2007
    Posts
    6

    Re: GDI+ Bitmap size limitation?

    That's a pretty big bitmap...
    i think you're right in that it might be limited to a signed short in either direction.
    which limits the maximum size of a bitmap to slightly below 24 gigabytes.

    32767 * 32767 * 24 (bits pr pixel) = 25768230936 bytes
    25768230936 / 1024^3 = 23.998535

    now I'm not saying you'll never need that big bitmaps, i'm just saying that if you need a bitmap that big, you'll probably need to implement it yourself..

    just out of curiousity, what are you using it for?

  5. #5
    Join Date
    Dec 2006
    Posts
    5

    Re: GDI+ Bitmap size limitation?

    Nobody spoke of using a bitmap with size 2^15 X 2^15;

    I need to display some wich may be up to a few tens of thousands of pixels high (displayed in a scrollable view), but only a few dozen pixel wide.
    Used for some exotic legends in map display.

    Of course there are workarounds (which I do find awkward, especially after Microsoft boasted about overcoming 16bit limitiations with GDI+)

    Thx for answering,

    -Metaspace

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured