[Gambas-user] Picture.ToString() ?

vuott at tutanota.com vuott at tutanota.com
Sat Dec 30 13:14:22 CET 2023


Hello,
if you want to send "pure" image data, "perhaps" you could do this:

- To send blocks of "Integer" data converted to memory representation as a 4-character string:

  Public Sub PictureToString(Pic As Picture) As String
    
    Dim s As String
  
    For Each i As Integer In pc.Image.Pixels
      s &= MkInt(i)
    Next
 
    Return s
 
  End


- To send blocks of individual "Byte "data converted to memory representation as a 1-character string:

  Public Sub PictureToString(Pic As Picture) As String
    
    Dim s As String
  
    For i As Integer = 0 To (pc.Image.Pixels.Max * (pc.Depth / 8))
      s &= MkByte(Byte@(pc.Image.Data + i))
    Next
 
    Return s
 
  End






30 dic 2023, 01:46 da bsteers4 at gmail.com:

> If there any simpler (non-file) way to get the opposite of Picture.FromString()
> I wanted a way to transmit image data using Print in Task.class.
>
> This works for me but wondered if there was a faster way than a physical file?
>
>
> Public Sub PictureToString(Pic As Picture) As String
>   
>   Dim sTmp As String = File.SetExt(Temp("tmp-pic"), "png")
>   Pic.Save(sTmp)
>   Return File.Load(sTmp)
>   
> End
> Respects
> BruceS
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231230/39f7d85b/attachment.htm>


More information about the User mailing list