Hi all, I know there is ability to load an image from a file, while its tremendously simple and straightforward. BUT I'd like to write a light weight image editing open source application, that based on Shoes. for example generate a 3D image (using 3d glasses), stitch a multi image for a panorama image. (btw I will use RMagick to do this things.) Shoes has to reload the new image from a file after every action is applied, it cannot directly access a byte array to generate this, which decrease the performance of the app. Is that possible shoes to load the bitmap image from byte array? which it is used in ruby HornetsEye. So to increase the performance?
On Sun, Aug 22, 2010 at 11:19 PM, Yiling Cao <yiling.cao@cndevteam.com>wrote: > Hi all, > > I know there is ability to load an image from a file, while its > tremendously simple and straightforward. > > BUT > > I'd like to write a light weight image editing open source application, > that based on Shoes. for example generate a 3D image (using 3d glasses), > stitch a multi image for a panorama image. (btw I will use RMagick to do > this things.) > > Shoes has to reload the new image from a file after every action is > applied, it cannot directly access a byte array to generate this, which > decrease the performance of the app. > > Is that possible shoes to load the bitmap image from byte array? which it > is used in ruby HornetsEye. So to increase the performance? > That was something I was pushing for before _why left. The code is there, it just hasn't been all wired up yet, and I don't know enough to do this currently. The syntax _why and I came up with: image :data => (String) So you'd have to convert your byte array into a string first. Strings are more efficient in Ruby anyway. -- ~devyn
On Mon, 2010-08-23 at 19:54 -0700, Devyn Cairns wrote: > That was something I was pushing for before _why left. The code is > there, it just hasn't been all wired up yet, and I don't know enough > to do this currently. > > > The syntax _why and I came up with: > > > image :data => (String) > > > So you'd have to convert your byte array into a string first. Strings > are more efficient in Ruby anyway. Huh? Binary date in a image buffer should not be subject to the slings and arrows of UTF-8 in Ruby 1.9+ > > -- > ~devyn >
On Mon, Aug 23, 2010 at 8:06 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > On Mon, 2010-08-23 at 19:54 -0700, Devyn Cairns wrote: > > > That was something I was pushing for before _why left. The code is > > there, it just hasn't been all wired up yet, and I don't know enough > > to do this currently. > > > > > > The syntax _why and I came up with: > > > > > > image :data => (String) > > > > > > So you'd have to convert your byte array into a string first. Strings > > are more efficient in Ruby anyway. > > Huh? Binary date in a image buffer should not be subject to the slings > and arrows of UTF-8 in Ruby 1.9+ > You and your encoding issues ;] It's really not that hard, things just behave a bit differently. Just use ASCII-8BIT and all will be well. > > > > -- > > ~devyn > > > > > -- ~devyn
On Tue, 2010-08-24 at 19:44 -0700, Devyn Cairns wrote: > > Huh? Binary date in a image buffer should not be subject to > the slings > and arrows of UTF-8 in Ruby 1.9+ > > > You and your encoding issues ;] It's really not that hard, things just > behave a bit differently. Just use ASCII-8BIT and all will be well. It's not my encoding issues. It's about an API that doesn't exist yet. The encoding of images is binary (bitstreams, endian sensitive, in byte[]). They are not character streams in any part of the post 1.8.7 world. They are bytes[] and that is how Shoes should treat them. No encoding at all. They aren't character strings. String Ascii-8bit on a image byte stream is a hack to make string work where it shouldn't and it's not needed. Nothing wrong with hacks to get something to work, but why ruin a proposed api with a misunderstanding. > > > > > -- > > ~devyn > > > > > > > > -- > ~devyn
On Tue, Aug 24, 2010 at 9:03 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > On Tue, 2010-08-24 at 19:44 -0700, Devyn Cairns wrote: > > > > > Huh? Binary date in a image buffer should not be subject to > > the slings > > and arrows of UTF-8 in Ruby 1.9+ > > > > > > You and your encoding issues ;] It's really not that hard, things just > > behave a bit differently. Just use ASCII-8BIT and all will be well. > It's not my encoding issues. It's about an API that doesn't exist yet. > > The encoding of images is binary (bitstreams, endian sensitive, in > byte[]). They are not character streams in any part of the post 1.8.7 > world. They are bytes[] and that is how Shoes should treat them. No > encoding at all. They aren't character strings. > Well, then feel free to code a type in C for them; Arrays of Fixnums use a *lot* of memory (I'm fairly sure it's quite a bit more) in comparison to a String holding the same data. …*or* you could just subclass String. > > String Ascii-8bit on a image byte stream is a hack to make string work > where it shouldn't and it's not needed. Nothing wrong with hacks to get > something to work, but why ruin a proposed api with a misunderstanding. > > > > > > > > > -- > > > ~devyn > > > > > > > > > > > > > > > -- > > ~devyn > > > -- ~devyn
will.not.mention.byte[].are.not.a.sublcass.of.Fixnum.or.String.Valueable.debugging.time.lost. On Tue, 2010-08-24 at 21:14 -0700, Devyn Cairns wrote: > > > On Tue, Aug 24, 2010 at 9:03 PM, Cecil Coupe <ccoupe@cableone.net> > wrote: > On Tue, 2010-08-24 at 19:44 -0700, Devyn Cairns wrote: > > > > > Huh? Binary date in a image buffer should not be > subject to > > the slings > > and arrows of UTF-8 in Ruby 1.9+ > > > > > > You and your encoding issues ;] It's really not that hard, > things just > > behave a bit differently. Just use ASCII-8BIT and all will > be well. > > It's not my encoding issues. It's about an API that doesn't > exist yet. > > The encoding of images is binary (bitstreams, endian > sensitive, in > byte[]). They are not character streams in any part of the > post 1.8.7 > world. They are bytes[] and that is how Shoes should treat > them. No > encoding at all. They aren't character strings. > > > Well, then feel free to code a type in C for them; Arrays of Fixnums > use a *lot* of memory (I'm fairly sure it's quite a bit more) in > comparison to a String holding the same data. > > > …or you could just subclass String. > > > String Ascii-8bit on a image byte stream is a hack to make > string work > where it shouldn't and it's not needed. Nothing wrong with > hacks to get > something to work, but why ruin a proposed api with a > misunderstanding. > > > > > > > > > -- > > > ~devyn > > > > > > > > > > > > > > > -- > > ~devyn > > > > > > -- > ~devyn
I know what byte[] are. But Ruby doesn't provide that. So, you have a choice: [72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100] # Array of Fixnum "Hello, world" # String The difference between them (other than syntax, but that doesn't matter in the least for this purpose) is that for an Array of Fixnum, Ruby will do this: * * Array object (Ruby object header stuff) length pointer to first element Fixnum object (Ruby object header stuff) somewhere around there, the value Fixnum object (Ruby object header stuff) somewhere around there, the value … Not to mention all of the slots for all of the objects, etc. Bottom line: it's a waste of a lot of memory. Now, let's look at a String: String object (Ruby object header stuff) length encoding char* See? In a string, the bytes are just stored one after another; a char*. In an Array, each byte is its own object, meaning several (hundreds of) extra bytes per byte. However, Yiling seemed to suggest that whatever API they're using has a two-dimensional byte array class. The thing is, how do we get this into Shoes? We'd need some general interface that the :data => parameter can take. Perhaps this could be accomplished through an iterator? I don't know. On Tue, Aug 24, 2010 at 9:35 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > > will.not.mention.byte[].are.not.a.sublcass.of.Fixnum.or.String.Valueable.debugging.time.lost. > > On Tue, 2010-08-24 at 21:14 -0700, Devyn Cairns wrote: > > > > > > On Tue, Aug 24, 2010 at 9:03 PM, Cecil Coupe <ccoupe@cableone.net> > > wrote: > > On Tue, 2010-08-24 at 19:44 -0700, Devyn Cairns wrote: > > > > > > > > Huh? Binary date in a image buffer should not be > > subject to > > > the slings > > > and arrows of UTF-8 in Ruby 1.9+ > > > > > > > > > You and your encoding issues ;] It's really not that hard, > > things just > > > behave a bit differently. Just use ASCII-8BIT and all will > > be well. > > > > It's not my encoding issues. It's about an API that doesn't > > exist yet. > > > > The encoding of images is binary (bitstreams, endian > > sensitive, in > > byte[]). They are not character streams in any part of the > > post 1.8.7 > > world. They are bytes[] and that is how Shoes should treat > > them. No > > encoding at all. They aren't character strings. > > > > > > Well, then feel free to code a type in C for them; Arrays of Fixnums > > use a *lot* of memory (I'm fairly sure it's quite a bit more) in > > comparison to a String holding the same data. > > > > > > …or you could just subclass String. > > > > > > String Ascii-8bit on a image byte stream is a hack to make > > string work > > where it shouldn't and it's not needed. Nothing wrong with > > hacks to get > > something to work, but why ruin a proposed api with a > > misunderstanding. > > > > > > > > > > > > > -- > > > > ~devyn > > > > > > > > > > > > > > > > > > > > > > -- > > > ~devyn > > > > > > > > > > > > -- > > ~devyn > > > -- ~devyn
On Wed, 2010-08-25 at 18:38 -0700, Devyn Cairns wrote: > I know what byte[] are. But Ruby doesn't provide that. So, you have a > choice: Well, damn. Somehow I thought that was something new with 1.9.1.
I've only been half-following this thread, but... > $ irb > ruby-1.9.2-p0 > "".methods.grep /byte/ > => [:bytesize, :getbyte, :setbyte, :bytes, :each_byte] is String#bytes not what you're looking for? > ruby-1.9.2-p0 > "Shoes".each_byte {|b| puts b} > 83 > 104 > 111 > 101 > 115 On Wed, Aug 25, 2010 at 10:06 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > On Wed, 2010-08-25 at 18:38 -0700, Devyn Cairns wrote: >> I know what byte[] are. But Ruby doesn't provide that. So, you have a >> choice: > > Well, damn. Somehow I thought that was something new with 1.9.1. > > > >
Yeah, I know about that. Cecil was just all anti-String as byte[] ;] The behavior's a bit different in 1.9 but it's been around for ages. On Wed, Aug 25, 2010 at 7:16 PM, Steve Klabnik <steve@steveklabnik.com>wrote: > I've only been half-following this thread, but... > > > $ irb > > ruby-1.9.2-p0 > "".methods.grep /byte/ > > => [:bytesize, :getbyte, :setbyte, :bytes, :each_byte] > > is String#bytes not what you're looking for? > > > ruby-1.9.2-p0 > "Shoes".each_byte {|b| puts b} > > 83 > > 104 > > 111 > > 101 > > 115 > > On Wed, Aug 25, 2010 at 10:06 PM, Cecil Coupe <ccoupe@cableone.net> wrote: > > On Wed, 2010-08-25 at 18:38 -0700, Devyn Cairns wrote: > >> I know what byte[] are. But Ruby doesn't provide that. So, you have a > >> choice: > > > > Well, damn. Somehow I thought that was something new with 1.9.1. > > > > > > > > > -- ~devyn
Hi Yiling, > Shoes has to reload the new image from a file after every action is applied Umm... sorry, what do you mean, 'after every action is applied?' The `image` method works in the another thread. So, your app will not stop. > Is that possible shoes to load the bitmap image from byte array? I'm not sure what you want to do, sorry. But, if you can write the code in Ruby, almost all of the code are available in Shoes. ashbb
On Mon, Aug 23, 2010 at 9:59 PM, ashbb <ashbbb@gmail.com> wrote: > Hi Yiling, > > > > Shoes has to reload the new image from a file after every action is > applied > Umm... sorry, what do you mean, 'after every action is applied?' > The `image` method works in the another thread. So, your app will not stop. > > What I mean is for example, in Photoshop, if you apply an image mask, or smooth operation, a new image will be displayed immediately after you applied this action. What I can do now in shoes is when i apply smooth operation, RMagick will do the operation for you and save to a file. I will have to reload the image from disk, not directly from memory. this decrease performance dramatically. > > > Is that possible shoes to load the bitmap image from byte array? > I'm not sure what you want to do, sorry. > But, if you can write the code in Ruby, almost all of the code are > available in Shoes. > > ashbb > what HornetsEye is they are using MultiArrary, a 2D byte array, you can have a look at here: http://www.wedesoft.demon.co.uk/hornetseye-api/files/interactive-txt.html There is also some video example how this happen in action on the homepage of this software.
Hi Yiling, Ohh, I understand now. Thank you so much for the interesting information. As Devyn mentioned, Shoes 3 doesn't have the feature. We should add the feature to the todo list for WalkAbout. ;-) ashbb