Forum: Ruby RMagick exporting pixels as string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E20e89d58211a3631842daecc1245de2?d=identicon&s=25 Ilmari Heikkinen (Guest)
on 2006-01-07 11:08
(Received via mailing list)
Hi,

I'm exporting pixels to an OpenGL texture from Magick::Image
using export_pixels.

The problem is that it's slow.
5.5 seconds for a 330x370 image -slow.

Is there a faster way to do this:

image.export_pixels(0,0, cols, rows, "BGRA").pack("c*")

Thanks in advance,
Ilmari
E20e89d58211a3631842daecc1245de2?d=identicon&s=25 Ilmari Heikkinen (Guest)
on 2006-01-07 11:29
(Received via mailing list)
On 1/7/06, Ilmari Heikkinen <ilmari.heikkinen@gmail.com> wrote:
> image.export_pixels(0,0, cols, rows, "BGRA").pack("c*")
Did some more timing and pinpointed the problem:
export-bgra: 0.557612
pack: 4.761164

export_pixels isn't quite the speed demon, but pack's
the real problem.
4913bcb685792f601ae9813b4713abb9?d=identicon&s=25 Detlef Reichl (Guest)
on 2006-01-07 12:51
(Received via mailing list)
Am Samstag, den 07.01.2006, 19:29 +0900 schrieb Ilmari Heikkinen:
> >
> > image.export_pixels(0,0, cols, rows, "BGRA").pack("c*")
>
>
> Did some more timing and pinpointed the problem:
> export-bgra: 0.557612
> pack: 4.761164
>
> export_pixels isn't quite the speed demon, but pack's
> the real problem.

Hi,

try image.to_blob, that will return the image data as a string.

Cheer
detlef
E20e89d58211a3631842daecc1245de2?d=identicon&s=25 Ilmari Heikkinen (Guest)
on 2006-01-07 15:05
(Received via mailing list)
On 1/7/06, Detlef Reichl <detlef.reichl@gmx.org> wrote:
> > > Is there a faster way to do this:
>
> Hi,
>
> try image.to_blob, that will return the image data as a string.
>
> Cheer
> detlef

Thank you so much, that did the trick.

Now it's taking just 0.16s to get the pixels. Also, the image was
actually 1000x1000 pixels, brainfart on my side.
(As a sidenote, Imlib2's doing the same in 0.016s.)
This topic is locked and can not be replied to.