[Gambas-user] Picture.ToString() ?

Bruce Steers bsteers4 at gmail.com
Sat Dec 30 19:40:50 CET 2023


On Sat, 30 Dec 2023 at 17:47, Gianluigi <gradobag at gradobag.it> wrote:

>
> HI,
>
> sorry, I'm back now and I gave it a quick read, I didn't understand why
> you can't use File.Load()
>

Maybe have a longer read then ;)

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.

For me it was to send image data using Task.class that is limited to only
String datatype.

It seems logical that if there is Picture.FromString then there may be a
ToString alternative.

Welcome back :)
BruceS



> Regards
> Gianluigi
>
> Il 30/12/23 16:02, Claus Dietrich ha scritto:
> > 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
> >>
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231230/dec61821/attachment.htm>


More information about the User mailing list