Closed KeyWorksRW closed 1 year ago
Another possible option would be to create a class, similar to the following:
require 'base64'
class RubyEmbeddedImage
def initialize(data, isBase64=true)
@data = data
@isBase64 = isBase64
end
def get_data
data = @data
if @isBase64
data = Base64.decode64(@data)
end
data
end
def get_image
stream = StringIO.new(get_data)
Wx::Image.new(stream)
end
end
my_image_data = <<~BASE64
SGVsbG8sIHdvcmxkIQ==
BASE64
my_image = RubyEmbeddedImage(my_image_data).get_image()
I haven't tried any of this, so it would probably need some tweaking, but in theory something like this should work. This would be in the images.rb file we generate so that all the app's images could potentially be in one place.
Embedding of bitmaps is now working fine within a form. The Images form still needs this implemented. I'm waiting to find out if the various from_()
functions will be implemented in wxRuby3 before adding support for embedded SVG files.
The Image list has been implemented in Ruby. SVG files are also now supported via zip compression/decompression.
Description:
wxRuby3 doesn't have anything equivalent to PyEmbeddedImage which made it easy to embed images into wxPython. We could probably do something similar using base64 encoding:
For SVG images, we could treat it similar to how we do it in Python -- first use zlib to compress the string, then store it in the file as Base64 and finally using zlib.decompress(Base64.decode64(...))