PictureToString and StringToPicture

FUNCTION PictureToString(p as picture) as string '// Convert a picture to a String If p=Nil Then Return "" Return EncodeBase64(p.GetData(Picture.FormatPNG),0) END FUNCTION FUNCTION StringToPicture(data as string) as picture '// Convert a String to a picture Dim p As picture If data="" Then Return Nil p=picture.FromData(DecodeBase64(data)) p.transparent=1 Return p END FUNCTION
This snippet was originally posted by Dave Sisemore back in 2013. I needed it today to compare two pictures, and was glad to find it.

It can also be used to place pictures in constants and create them on the fly upon run, to avoid them to show in the Resources folder.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.