Re: [Fxruby-users] Copying an Image with FXMemoryStream?
Status: Inactive
Brought to you by:
lyle
|
From: Carsten E. <ca...@ci...> - 2004-01-04 11:59:14
|
Lyle Johnson wrote:
> Based on the error message, there's probably a bug with the wrapping
> of FXMemoryStream, and I will need to take a look. In the meantime, if
> it's acceptable to use a temporary file you can just save the image
> out to disk and re-load it for the copy, i.e.
>
> # Save orig_img to a file on disk (tmpfile.jpg)
> FXFileStream.open("tmpfile.jpg", FXStreamSave) do |stream|
> fxsaveJPG(stream, orig_img.data.to_s, 0,
> orig_img.width, orig_img.height, orig_img.quality)
> end
>
> # Reload it and make a new FXJPGImage
> dest_img = nil
> File.open("tmpfile.jpg", "rb") do |file|
> dest_img = FXJPGImage.new(app, file.read,
> IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
> end
Lyle,
thanks this helps a bit (it gets my app going), but it's VERY SLOW. I'm
writing an ImageView Widget that doesn't scroll, but scales the image
according to the window size. This means, that with every SEL_PAINT
message I need to copy a back_image to the front_image, you can imagine
how slow the drawing is, when copying via files.
BTW: you can download the source code for the FXScaleImageView from
http://carsten.circle42.com/source/ScaleImage/FXScaleImageView and a
test program from
http://careck.circle42.com/source/ScaleImage/TestFXScaleImageView
|