Hi, But I don't want to create this dependency with a file path.I load a PNG file using the code below: pngPath := '/Users/Somefolder/UI-Theme.png' asFileReference. forms := pngPath readStreamDo: [ :in | (PNGReadWriter on: in) nextImage ]. ... |
Look at the icons because they are managed like an encoded byte
array.
Le 15/5/15 21:11, Leonardo Silva a
écrit :
|
You can also use this utility to simplify generation of the array. Peter On Fri, May 15, 2015 at 9:37 PM, stepharo <[hidden email]> wrote:
|
You can encore your image in base64 anImage := 'holidays.png' asFileReference readStream binary. encodedImage := Base64MimeConverter mimeEncode: anImage. Then you can decode it with: ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: encodedImage). Is this what you were searching for ? 2015-05-15 22:47 GMT+02:00 Peter Uhnák <[hidden email]>:
|
On Sat, May 16, 2015 at 5:28 PM, Merwan Ouddane <[hidden email]> wrote:
Yes, this is cool! I understand that encodedImage is a ReadWriteStream. So, I use 'encodedImage contents' to get the code as string. Then I assigned the code to a variable, like that: classVariable := 'iVBORw0KGgoAAAANSUhEUgAAAmAAAAIHCAIAAAC3HdQEQUJUQQJEcEAFRVE...' But I don't know how to transform it back. I tried the following: test := ReadWriteStream on: classVariable. ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: test). But it doesn't work. It gives me an 'Error: image format not recognized' Do you know what I am missing here ? Thank you |
"Quick and easy way to get an image from a URL"
ZnEasy getPng: 'http://www.pharo.org/files/pharo.png'. "Turn bytes into an image inside Pharo" (PNGReadWriter on: 'http://www.pharo.org/files/pharo.png' asUrl retrieveContents readStream) nextImage. "Store image bytes as Base64 and recreate the image" | base64 | base64 := ZnBase64Encoder new encode: 'http://www.pharo.org/files/pharo.png' asUrl retrieveContents. (PNGReadWriter on: (ZnBase64Encoder new decode: base64) readStream) nextImage. > On 17 May 2015, at 08:55, Leonardo Silva <[hidden email]> wrote: > > > On Sat, May 16, 2015 at 5:28 PM, Merwan Ouddane <[hidden email]> wrote: > You can encore your image in base64 > anImage := 'holidays.png' asFileReference readStream binary. > encodedImage := Base64MimeConverter mimeEncode: anImage. > > > Then you can decode it with: > ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: encodedImage). > > > Is this what you were searching for ? > > Yes, this is cool! > I understand that encodedImage is a ReadWriteStream. So, I use 'encodedImage contents' to get the code as string. > Then I assigned the code to a variable, like that: > > classVariable := 'iVBORw0KGgoAAAANSUhEUgAAAmAAAAIHCAIAAAC3HdQEQUJUQQJEcEAFRVE...' > > But I don't know how to transform it back. I tried the following: > > test := ReadWriteStream on: classVariable. > ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: test). > > But it doesn't work. It gives me an 'Error: image format not recognized' > > Do you know what I am missing here ? > > Thank you > |
Free forum by Nabble | Edit this page |