Loading an Image/Picture from memory

Post Reply
computermouth
Posts: 4
Joined: Wednesday 09th May 2018 5:12am

Loading an Image/Picture from memory

Post by computermouth » Monday 28th May 2018 5:26am

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!

vuott
Posts: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: Loading an Image/Picture from memory

Post by vuott » Monday 28th May 2018 2:04pm

Excuse me,
why Base64 ? :|

computermouth
Posts: 4
Joined: Wednesday 09th May 2018 5:12am

Re: Loading an Image/Picture from memory

Post by computermouth » Monday 28th May 2018 7:10pm

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.

vuott
Posts: 16
Joined: Wednesday 05th April 2017 6:07pm

Re: Loading an Image/Picture from memory

Post by vuott » Monday 28th May 2018 7:36pm

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

Post Reply