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