Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Repost - Larger image problems
Repost - Larger image problems [message #452554] Tue, 22 March 2005 08:44 Go to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

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)
at
ro.zerosoft.swt.test.ComponentTest.createPrintPreviewSample( ComponentTest.ja
va:965)
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 ?

Regards,
Boby
Re: Repost - Larger image problems [message #452605 is a reply to message #452554] Wed, 23 March 2005 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: doug-list.threepenny.net

Robert,

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.

Doug


Robert Bacs wrote:

> Hi,
>
> 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)
> at
> ro.zerosoft.swt.test.ComponentTest.createPrintPreviewSample( ComponentTest.ja
> va:965)
> 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 ?
>
> Regards,
> Boby
>
>
Re: Repost - Larger image problems [message #454309 is a reply to message #452605] Wed, 20 April 2005 02:01 Go to previous messageGo to next message
Ian Graham is currently offline Ian GrahamFriend
Messages: 24
Registered: July 2009
Junior Member
On Wed, 23 Mar 2005 00:36:50 -0800, Doug Pearson =

<doug-list@threepenny.net> wrote:

> 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 =
to =

create larger bitmaps, that'd be really helpful, so I've filed =

https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D92017.

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 :)

Ian
Re: Repost - Larger image problems [message #454446 is a reply to message #452605] Wed, 20 April 2005 21:41 Go to previous message
Ian Graham is currently offline Ian GrahamFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks for the tip Doug! I posted it as an ehancement request last nig=
ht =

and Silenio and Christophe have incorporated it so fast it made my head =
=

spin!

Cheers,
Ian
Previous Topic:Expanding a TreeItem in swt.Tree
Next Topic:How to get the list of available font size of a font?
Goto Forum:
  


Current Time: Thu Apr 25 17:13:59 GMT 2024

Powered by FUDForum. Page generated in 0.03472 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top