Displaying an image from a file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying an image from a file

laura
Hi all,
How can i make a morph display an image from a file at my hd? How can i further "save" this image inside a class so to be ported via packages?
Thanks,
Laura
Reply | Threaded
Open this post in threaded view
|

Re: Displaying an image from a file

Tudor Girba-2
Just look at FileReference>>gtInspectorPngIn: 

To see the effect, inspect the a .png file reference.

Cheers,
Doru



On Sat, Jun 27, 2015 at 5:15 PM, Laura Risani <[hidden email]> wrote:
Hi all,
How can i make a morph display an image from a file at my hd? How can i further "save" this image inside a class so to be ported via packages?
Thanks,
Laura



--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: Displaying an image from a file

Peter Uhnak
As for the saving, you can also look at http://smalltalkhub.com/#!/~peteruhnak/IconFactory (or just browse ThemeIcons, which is already present in the image), which stores the images in methods as base64 strings.

Peter

On Sat, Jun 27, 2015 at 5:20 PM, Tudor Girba <[hidden email]> wrote:
Just look at FileReference>>gtInspectorPngIn: 

To see the effect, inspect the a .png file reference.

Cheers,
Doru



On Sat, Jun 27, 2015 at 5:15 PM, Laura Risani <[hidden email]> wrote:
Hi all,
How can i make a morph display an image from a file at my hd? How can i further "save" this image inside a class so to be ported via packages?
Thanks,
Laura



--

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: Displaying an image from a file

Sven Van Caekenberghe-2
In reply to this post by laura
Here are two examples that contain elements of what you want:

(ZnEasy getPng: 'http://pharo.org/web/files/pharo.png')
  asMorph openInWindow.

(FileLocator workingDirectory filesMatching: '*.jpg') do: [ :each |
  (each withExtension: 'png') writeStreamDo: [ :out |
    each readStreamDo: [ :in |
      (PNGReadWriter on: out) nextPutImage:
        (JPEGReadWriter on: in) nextImage ] ] ]

Seaside has file library objects that store images and other resources as methods.

> On 27 Jun 2015, at 17:15, Laura Risani <[hidden email]> wrote:
>
> Hi all,
> How can i make a morph display an image from a file at my hd? How can i further "save" this image inside a class so to be ported via packages?
> Thanks,
> Laura


Reply | Threaded
Open this post in threaded view
|

Re: Displaying an image from a file

laura
Ok ! The snippet explained the reading from file, and ThemeIcons explained the saving-to/loading-from method.

On Sat, Jun 27, 2015 at 2:20 PM, Sven Van Caekenberghe <[hidden email]> wrote:
Here are two examples that contain elements of what you want:

(ZnEasy getPng: 'http://pharo.org/web/files/pharo.png')
  asMorph openInWindow.

(FileLocator workingDirectory filesMatching: '*.jpg') do: [ :each |
  (each withExtension: 'png') writeStreamDo: [ :out |
    each readStreamDo: [ :in |
      (PNGReadWriter on: out) nextPutImage:
        (JPEGReadWriter on: in) nextImage ] ] ]

Seaside has file library objects that store images and other resources as methods.

> On 27 Jun 2015, at 17:15, Laura Risani <[hidden email]> wrote:
>
> Hi all,
> How can i make a morph display an image from a file at my hd? How can i further "save" this image inside a class so to be ported via packages?
> Thanks,
> Laura