|Re: Repost - Larger image problems [message #452605 is a reply to message #452554]
||Wed, 23 March 2005 08:36
Originally posted by: doug-list.threepenny.net|
The new Image object ends up calling CreateCompatibleBitmap (which you
can look up on MSDN -- it's the one with the 16MB Win9x limit).
This call by default creates a DDB -- Device Dependent Bitmap. Those
are generally created directly in your video card's memory and are
therefore limited in size. E.g. a 32-bit 4000x4500 pixel image is 72MB.
If your video card is smaller than that you're hosed (even if it's
larger it won't let you have all the VRAM for just your bitmap).
In Windows the fix is to create a DIB instead -- a Device Independent
Bitmap. Those are stored in main memory and can be any size at all.
The decision about which gets created hinges on the way the device
context is created which is then handed to CreateCompatibleBitmap and
that's where the problem lies. SWT could call CreateDIBSection before
the CreateCompatibleBitmap call, but apparently it doesn't (I'm just
looking at the Java source--you'd need to dig into the C++ code to
really verify this).
So I'm pretty sure that's the underlying problem and to fix it one would
need to change the native SWT C++ source, which may be feasible if
you're up to the Windows coding challenges.
Robert Bacs wrote:
> I have the following problem:
> Image image = new Image(getDisplay(), 4000, 4500);
> With the above line I get th following error:
> org.eclipse.swt.SWTError: No more handles
> at org.eclipse.swt.SWT.error(SWT.java:2717)
> at org.eclipse.swt.graphics.Image.init(Image.java:1366)
> at org.eclipse.swt.graphics.Image.<init>(Image.java:161)
> at ro.zerosoft.swt.PrintPreview.<init>(PrintPreview.java:107)
> at ro.zerosoft.swt.PrinterClass.<init>(PrinterClass.java:70)
> at ro.zerosoft.swt.PrinterClass.<init>(PrinterClass.java:49)
> ro.zerosoft.swt.test.ComponentTest.createPrintPreviewSample( ComponentTest.ja
> at ro.zerosoft.swt.test.ComponentTest.main(ComponentTest.java:5 9)
> Exception in thread "main"
> I've searched over the newsgroup and I find an unanswered post with
> "Workaround for larger images ?" subject and found in the MSDN that only on
> "Win95/98/ME: The created bitmap cannot exceed 16MB in size.", I'm running
> on Windows 2000.
> So my question is that there is a limitation on Win 2000 also, or there is a
> problem in JNI of SWT ?
|Re: Repost - Larger image problems [message #454309 is a reply to message #452605]
||Wed, 20 April 2005 02:01
| Ian Graham
Registered: July 2009
On Wed, 23 Mar 2005 00:36:50 -0800, Doug Pearson =|
> The decision about which gets created hinges on the way the device =
> context is created which is then handed to CreateCompatibleBitmap and =
> that's where the problem lies. SWT could call CreateDIBSection before=
> the CreateCompatibleBitmap call, but apparently it doesn't (I'm just =
> looking at the Java source--you'd need to dig into the C++ code to =
> really verify this).
I too am encountering this image size limitation, although it would be =
less of an issue if I could create an Image of lower depth than the =
Display. But if there IS a simple modification to allow SWT on Windows =
create larger bitmaps, that'd be really helpful, so I've filed =
However, Doug, isn't all the code written in Java where you can clearly =
see what goes on? For instance I can see from Image.init(Device,int,int=
and Display.internal_new_GC() exactly how the device context is created,=
by invoking OS.GetDC(0). Since pretty well all the OS calls seem to be =
available almost directly through org.eclipse.swt.internal.win32.OS I =
would think it should be fairly straightforward for a Windows guru to =
enhance the SWT Image support to optionally use DIBs(especially since I =
guess that could also enable offering support for Images with palettes =
other than RGB).
I would certainly appreciate it if you could :)
Powered by FUDForum
. Page generated in 0.01650 seconds