[Gambas-user] Picture.ToString() ?

Claus Dietrich claus.dietrich at freenet.de
Sat Dec 30 16:02:59 CET 2023


Sorry, I just found a number of posts as spam at my email provider - 
incl. the image-data solution of Vuott:

   Public Sub PictureToString(Pic As Picture) As String

     Dim s As String

     For i As Integer = 0 To (pic.Image.Pixels.Max * (pic.Depth / 8))
       s &= MkByte(Byte@(pic.Image.Data + i))
     Next

     Return s

   End

I get the error "wrong argument" (@ i=0) in the line

s &= MkByte(Byte@(pic.Image.Data + i))

With a PictureToString-function I just would like achieve the same as with

     Dim sTmp As String = File.SetExt(Temp("tmp-pic"), "jpg")
     Pic.Save(sTmp)
     Return File.Load(sTmp)

This means that I would have to pass the bitmap format (jpg, png, pnm) 
and possibly the depth.

Regards

Claus

Am 30.12.23 um 15:21 schrieb Claus Dietrich:
> Hi
>
> Why don't we have this function? I would have needed it many times 
> already and someone else recently asked me for that.
>
> Could the Data-property of the image class help to get a fast 
> solution? If so, how can it be used?
>
> Regards
>
> Claus
>
>
>> 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
>


More information about the User mailing list