[Gambas-user] Picture.ToString() ?
Bruce Steers
bsteers4 at gmail.com
Mon Jan 1 13:56:56 CET 2024
On Mon, 1 Jan 2024 at 05:46, BB <adamnt42 at gmail.com> wrote:
> On 30/12/23 11:15 am, Bruce Steers wrote:
>
> 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
>
> Ohohoo and a happy new year.
>
> For something to do I have waded through the QT4 and GTK Picture classes.
> It appears to me that adding a ToString() method for QT would be a simple
> ("hahaha" said the so-called C expert) matter as the underlying buffer into
> which the file is loaded does not appear to be destroyed while the Picture
> exists and it is essentially a byte array. Now for GTK, guess what?! The
> initial buffer is released after it is loaded and converted to a picture!
> So it is not going to be so simple to create a way to develop a simple
> ToString().
>
> I accept that this does not advance towards a solution but it may relieve
> some of your angst about the implied "Why isn't?
>
> cheers
>
> b
>
I see , cheers :)
It seems we already have the code though for all toolkits. just only with a
file save/load.
Either Picture.Save() (and Image.Save()) or File.Load() is already doing
the job of converting to string.
So could whatever method it is that's doing the conversion be exposed as a
function we could all use? to get the string data rather than saving it to
a file.
Respects
(and happy new year all :) )
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240101/b93b59c0/attachment.htm>
More information about the User
mailing list