image = ChunkyPNG::Image.from_file 'img.png'
@my_image = Gosu::Image.new image
rowsare undefined. Well, I created them quickly to fix that (example with ChunkyPNG):
def columns ; @width ; end
def rows ; @height ; end
Blob length mismatch (RuntimeError). But I checked,
rowsreturn the right value. I think it's related to compression level or something like that when generating the blob.
rowsreturn the right value but the blob is not accepted.
Canvas#to_blobreturns compressed data. The return value of
to_blobhas to have a length of either
columns * rows * 4or
columns * rows * 16(the latter is rare, when
to_rgba_streamreturns something that can be used with Gosu. In that case, you should probably create a wrapper for
ChunkyPNG::Canvasinstead of monkey-patching
Canvasand changing the names. Example (untested):
GosuWrapper = Struct.new(:columns, :rows, :to_blob)
GosuWrapper.new(@width, @height, to_rgba_stream)
MiniMagick::Image#to_blobis good for, it just seems to read a file (expand the source code): http://www.rubydoc.info/github/minimagick/minimagick/MiniMagick%2FImage%3Ato_blob
import_pixelsmethod that can import a "blob" (as defined by Gosu), but I can't find the other direction.
ChunkyPNGI think. The only interest I had in
MiniMagickwas the ability to load animated gif.
MiniMagickwas too big for what I needed.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill