Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, November 9, 2017 10:25:00 AM(UTC)
saholland

Groups: Registered
Posts: 1


I'm in the process of upgrading our code to replace LT v17 with LT v19.

I simply changed the project references, and everything compiled. So, I know the API I'm using hasn't changed.

But, at runtime, I'm getting an error that makes no sense. I'm using the RasterImagePainter.CreateGraphics() call to create a RasterGraphics object from a bitonal bitmap which uses the Format1bppIndexed pixel format. When I make the call to LT, I get an exception:
System.Exception: A Graphics object cannot be created from an image that has an indexed pixel format.

After some research I see this error is coming from the Microsoft GDI libraries, and it makes sense. I'm sending in an image type that GDI documentation says it doesn't support.

But, here's what does NOT make sense. I just did a drop-in replacement of v19 for v17. My code did not change. This same call to CreateGraphics with the same image worked just fine in LT v17.

I think the solution is to convert the image to a supported format before making the call. But that would impact performance. The only theory I have at the moment is that LT v17 was making this conversion behind the scenes for me, but v19 does not. If this is true, then doing the conversion myself would not impact performance.

Can anyone explain why v17 works in this scenario, but v19 does not?

Thanks.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, November 10, 2017 9:44:48 AM(UTC)

Walter  
Walter

Groups: Tech Support, Administrators
Posts: 368

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Hello,

I do not know for certain what changed between LEADTOOLS v17 and LEADTOOLS v19 that's causing this specifically. I know between LEADTOOLS 16.5 and 17.0 there were a lot of major changes made to our drawing code to refactor methods specific to WinForms as opposed to WPF and Silverlight. Some of this likely continued into later versions as well. LEADTOOLS also added support for other non-Windows platforms with LEADTOOLS 18 and LEADTOOLS 19 which also could have required some changes under the hood which might be having some effect here.

I double checked the documentation, and there isn't anything that clearly indicates a change was made that would cause this. Of the couple of changes that are listed in the Leadtools.Drawing assembly, none appear to specifically be related to the problem you're having now.

Both LEADTOOLS v17 and v19 provide methods for TestCompatible() and MakeCompatible(). You could test for compatibility ahead of trying to create a graphics object. If the test fails, then you will know there is a problem and should try to run the MakeCompatible(). In the remarks for both of these methods, there are requirements you could also check directly. If those are not all met, then do something different (try to MakeCompatible()) before continuing on with your existing code.

The extra checks to ensure compatibility would impact performance somewhat. I think the degree at which it will have an impact will depend on how many non-compatible images you will need to process. IMO, this is preferable over continuing as usual and trying to handle it after an exception occurs. That's up to each application developer to decide which is best for them though.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.135 seconds.