Ticket #9639 (closed enhancement: fixed)

Opened 21 months ago

Last modified 20 months ago

wxImage::GetType() enhancement

Reported by: troelsk Owned by:
Priority: normal Milestone:
Component: GUI-all Version: 2.9-svn
Keywords: wxImage wxBitmapType Cc:
Blocked By: Patch: yes
Blocking:

Description

This construct fails to report the file type

wxAnimate ani;
ani.Load("my.gif");
wxImage image = ani.GetFrame(0);
image.GetType() -> undefined
(expected wxBITMAP_TYPE_GIF - but wxImage::DoLoad is not called)

Patch:
- Add type parameter to wxImage::Create
- Use type parameter in calls to wxImage::Create, in the image decoders
- Remove wxImage::DoLoad type handling

Attachments

wximage-type-3.patch download (6.8 KB) - added by troelsk 21 months ago.

Change History

Changed 21 months ago by troelsk

Changed 21 months ago by vadz

  • status changed from new to infoneeded_new

I don't quite understand why isn't DoLoad() called in this case, could you please explain? TIA!

Concerning the patch itself, why does it call Create() with clear = true now? The default value of this parameter is false and I don't think it should be changed.

Changed 21 months ago by troelsk

  • status changed from infoneeded_new to new

I don't quite understand why isn't DoLoad() called in this case, could you please explain? TIA!

wxAnimate is calling wxGIFDecoder::Load directly. Later wxAnimate is calling wxGIFDecoder::ConvertToImage which in turn is calling wxImage::Create.
wxImage::DoLoad is never executed.

Concerning the patch itself, why does it call Create() with clear = true now?
The default value of this parameter is false and I don't think it should be changed.

The default value of clear is in fact "true" which is why I chose to use "true" in the patch.

Thanks
Troels

Changed 21 months ago by troelsk

In short, this solution should be more solid.
Hopefully GetType now is returning a valid value whenever possible.

Changed 20 months ago by vadz

  • status changed from new to closed
  • resolution set to fixed

I still think that specifying the type in the common wxImage code is a better idea than doing it in each of the handlers so I just added wxImage::SetType() and call it from animation decoder classes. This should be equivalent to your solution but I think it's preferable from maintainability point of view.

Thanks!

Note: See TracTickets for help on using tickets.