FXMemoryStream and FXJPGImage

Hi,

I’m trying to load an in memory JPG image (stored in a String object ) by
using a FXMemoryStream (seems to be the good kind of stream for that kind
of thing). However, I couldn’t understand how to use it:

The Constructor takes a “Data” object as parameter [1] but a Data object
cannot be instancied easily[2].

Moreover, the open() method of the FXMemoryStream does not seem to be
really bound (at least something odd is happening)[3].

I would like to proceed as follows if possible:

s being my jpeg string

img = FXJPGImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
FXMemoryStream.setData(s)
FXMemoryStream.open(FXStreamLoad) { |stream|
img.loadPixels(stream)
}

done !

But obviously, i missed something to make this work. Do you have any
suggestion ?

Thanks a lot! :slight_smile:

1:
irb(main):013:0> f = FXMemoryStream.new(“a”)
TypeError: wrong argument type String (expected Data)

2:
irb(main):015:0> d = Data.new()
NoMethodError: undefined method allocate' for Data:Class from (irb):15:innew’
from (irb):15
from c:/ruby-install/lib/ruby/site_ruby/1.7/i386-msvcrt/fox.so:0
3:
irb(main):024:0> f = FXMemoryStream.new()
#Fox::FXMemoryStream:0x5172980
irb(main):025:0> f.open()
ArgumentError: No matching function for overloaded 'FXMemoryStream_open’
from (irb):25:in `open’
from (irb):25
from c:/ruby-install/lib/ruby/site_ruby/1.7/i386-msvcrt/fox.so:0

···


Pierre Baillet
In the Kamigata area they have a sort of tiered lunchbox they use for a single
day when flower viewing. Upon returning, they throw them away, trampling them
underfoot. The end is important in all things.
Ghost Dog - The Way of the Samouraï

Pierre Baillet wrote:

I’m trying to load an in memory JPG image (stored in a String object ) by
using a FXMemoryStream (seems to be the good kind of stream for that kind
of thing). However, I couldn’t understand how to use it:

I’ll take a look at the issue(s) with FXMemoryStream on Monday; but if
you just need to construct an FXJPGImage and you already have the JPEG
image data in memory (as a String), you should be able to do so with:

 img = FXJPGImage.new(getApp(), s)

Hope this helps,

Lyle