[Gambas-user] Picture.ToString() ?

Claus Dietrich claus.dietrich at freenet.de
Sun Dec 31 13:06:25 CET 2023


Am 30.12.23 um 19:40 schrieb Bruce Steers:
> The initial objective was to avoid having to use a real file for speed.
> Just send picture data as a string, without having to save to a 
> physical file then re-read it with File.Load.
>
> It seems logical that if there is Picture.FromString then there may be 
> a ToString alternative.

Hi

I agree and also think of a Picture.ToString-method which provides a 
string representation of a bitmap file. The conversion routines proposed 
so far do something different. The following function is based on the 
one used by Bruce, but it utilizes a virtual file system located in the 
RAM instead of the physical hard-drive:

Public Sub PictureToString(Pic As Picture, sFormat as String, Optional 
iQuality as Integer = 100) As String

      Dim sPath As String

      Shell "echo $XDG_RUNTIME_DIR" Wait To sPath
      sPath = Trim(sPath) & "/tmppic." & sFormat
      Pic.Save(sPath, iQuality)
      Return File.Load(sPath)

End

I can imagine that an according picture/image-method for this would be 
useful particularly if it would be quicker.

Regards

Claus


More information about the User mailing list