[Gambas-user] Picture.ToString() ?

vuott at tutanota.com vuott at tutanota.com
Sun Dec 31 16:23:27 CET 2023


The use of the "Memory Stream" resource in "Read" mode would not be of added value compared to the use of Gambas' native "Byte@()" function for dereferencing Pointers.



31 dic 2023, 13:50 da bsteers4 at gmail.com:

>
>
> On Sun, 31 Dec 2023 at 12:07, Claus Dietrich <> claus.dietrich at freenet.de> > wrote:
>
>> 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
>>
>
> After a little research I found a possible solution, I just tried adding this line to my /etc/fstab file...
> tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=4G 0 0
>
> That made my /tmp folder a 4gb tmpfs ram disk thus technically negating this problem as using memory not hd is accomplished.
>
> But then everything on my computer worked except ALL of my gambas applications.
> It seemed to break gb.jit
> I could use my programs only by using env GB_NO_JIT=true ./appname.gambas
> Otherwise they all reported jit errors :(
>
> I agree a tmpfs location or any other ramdisk like you suggest should speed things up.  Using the XDG_RUNTIME_DIR seems like a pretty good solution :)
>
> I still think it should be possible to fake the disk access using Open Memory or something to save and reload the picture. (I just don't know how)
>
> Respects
> BruceS
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231231/b73366f2/attachment-0001.htm>


More information about the User mailing list