On Wed, Sep 12, 2012 at 11:39 AM, Vadim Zeitlin <
va...@wxwidgets.org> wrote:
> On Wed, 12 Sep 2012 07:51:44 +0400 Dimitri Schoolwerth wrote:
>
> DS> > Is there any benefit in putting the pngs in the resources in MSW over
> DS> > using bin2c and #including them as you would in Linux/OSX?
> DS>
> DS> I was wondering about that too,
>
> The main benefit is that it's the standard way of doing things under
> Windows. Of course, this kind of "we were always doing it like this so
> we're going to continue to do it like this" argument is not very
> convincing. But it does have a few concrete benefits too, e.g. you can use
> standard tools to add/view/edit PNGs to your application without
> recompiling it.
I totally forgot that a resource references files and that changes
made to the files will recompile the resources, this is quite useful
indeed.
> BTW, would anybody have any good naming ideas for the files containing
> these arrays with PNG data? I call them foo_png.c right now but it's not
> really a very good name.
FWIW the custom 'bin2c' I use does the same and by default converts
file.ext to file_ext.cpp and .h and uses file_ext[] as a variable.
> DS> Then also add a wxBitmap constructor+Create for the bin2c loading? I
> DS> don't think there is one currently, I see a ctor with a pointer but it
> DS> also takes width/height/depth while we probably need a pointer, a
> DS> length, and a wxBitmapType defaulting to PNG.
>
> So far I've added wxImage ctor and wxBitmapType doesn't have any default
> value as I'm afraid we'd run into some ambiguities otherwise. Do people
> think we should also have wxBitmap ctor like this? I'd prefer to avoid it
> and just use wxBitmap ctor from wxImage as above.
You are right, it makes sense to add the ctor to wxImage as that's
also the type used when loading images.
BTW, if we also wrap loading embedded PNGs into a macro
(wxBITMAP_EMBEDDED_PNG sounds fine) do we actually need another
wxImage ctor? It can already be accomplished using wxImage
image(wxInputStream& stream, wxBitmapType) and using a
wxMemoryInputStream as stream argument (this is what I use in my
LoadEmbeddedImage). It does require wxUSE_STREAMS of course.
> It would however make sense to have wxBitmap ctor from PNG if we could
> load PNG directly under some platform(s), without going through wxImage.
> I think in principle wxGTK might do this, e.g. we could presumably use
> gdk_pixbuf_new_from_stream()...
>
> So would you prefer to have a new
>
> wxBitmap(const void* data, size_t len, wxBitmapType type);
>
> ctor? I'm not sure if we're not going to get conflicts with the existing
>
> wxBitmap(const char* bits, int width, int height, int depth = 1);
I failed to see that ctor in wxBitmapBase. Anyway I think using
wxImage is fine and modifying wxBitmap in any way right now would feel
like premature optimisation.
Regards,
Dimitri