Closed blimmo closed 6 years ago
Indeed xpm is not working now, as the 2D char array doesn't correctly mapped. I will take a look at thatchar*
doesn't correctly mapped when it is used for binary data rather than a string
The mapping is updated. Now we can use a string slice to construct a wxImage
or wxBitmap
. Please have a check onexamples/webview
for usage reference
Thanks that's great!
On another note I'd like to use something like the wx.Bitmap.NewFromPNGData
method to display images from raw data (I have it in a []byte
).
The equivalent function in wxGo is wx.BitmapNewFromPNGData
but this takes a uintptr
so I'm not sure if this is wrapped properly?
Thanks again for the quick response on xpm :)
Updated, please check the webview example about the NewFromPNGData
Damn you're quick!
I notice you haven't freed the bitmap you've created in the example. Is this intentional and Bitmap
is memory managed or should I be calling wx.DeleteBitmap
?
Oh that is a mistake :(, and wx.DeleteBitmap
should be called. It seems that image
should also be deleted. I'll fix them
Actually could you add a T version which is managed by go like wx.NewBitmapT
? I often use it in a wx.NewStaticBitmap
and it would be nice to be able to use it inline.
My apologize - I was wrong in the previous reply - they are already tracked by Go. What these functions return are wxBitmap
and wxImage
(instead of a wxBitmap*
and wxImage*
). We can safely track them because nobody on C++ side would reference them.
Oh great!
Thanks for all your help on this :)
In wxWidgets in C, I've used the
wxBITMAP_PNG_FROM_DATA
macro along withxpm
files. Obviously this doesn't work in go so can anyone recommend an approach that does?I'd like to keep the images embedded in the executable and not separate. Also I'd prefer something cross platform (why I liked xpm so much).