Loading an Image/Picture from memory

Post

Posted
Rating:
#1 (In Topic #170)
Trainee
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

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

- 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

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!
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
Excuse me,
why Base64 ?   :|

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
Well, so I simply answer this your question:

computermouth said

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

Public Sub Form_Open()

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

End

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top
1 guest and 0 members have just viewed this.