Page 1 of 1

Loading an Image/Picture from memory

Posted: Monday 28th May 2018 5:26am
by computermouth
Hi folks,

I'm working on an image/animation editor. My editor needs to be able to import multiple images, stored as separate layers, which are eventually saved out in a custom file format.

Currently I have images being loaded in from their location on the filesystem:

Code: Select all

newLayer.B64Image = Base64$(File.Load(imagePath))
I'd like to draw this image to a Canvas. The intent is to make it so I don't have to pass around a copy of every image used in each layer, but rather just one file, each containing a b64 copy of all images used.

for example:

Code: Select all

- image:
  - Name: dogs
  - B64Image: abcdef[etc]
- image:
  - Name: cats
  - B64Image: abcdef[etc]
I've seen a couple solutions that involve writing out to temporary files, but I'd like to avoid that.

I see in the documentation that

Code: Select all

Picture.FromString()
at least existed at one point in time, but it seems to be deprecated in the version I'm using, as I only get errors when trying to use it.

Thanks!

Re: Loading an Image/Picture from memory

Posted: Monday 28th May 2018 2:04pm
by vuott
Excuse me,
why Base64 ? :|

Re: Loading an Image/Picture from memory

Posted: Monday 28th May 2018 7:10pm
by computermouth
Base64 because I want it to save all contents of the layered image out to a human-readable file.

Switching from b64 to bytes is a function call away, so if it's easier to think about, I suppose I should have posed the question like:

I have read in a PNG as a string of bytes, and I am looking for a way to convert that string of bytes to an Image or Picture type, to display to a canvas.

Re: Loading an Image/Picture from memory

Posted: Monday 28th May 2018 7:36pm
by vuott
Well, so I simply answer this your question:
computermouth wrote: Monday 28th May 2018 7:10pm I have read in a PNG as a string of bytes, and I am looking for a way to convert that string of bytes to an Image or Picture type, to display to a canvas.
...and this's my code: :|

Code: Select all

Public Sub Form_Open()

  Dim pc As Picture
    
   pc = Picture.FromString(File.Load("/path/of/file.png"))
    
   PictureBox1.Picture = pc

End