Ausdruck von Base64Encoded Bilder

Moderator: Moderatoren

Antworten
Benutzeravatar
jackDuijf
Rookie
Rookie
Beiträge: 4
Registriert: Mi, 10. Dez 2014 22:06
Kontaktdaten:

Ausdruck von Base64Encoded Bilder

Beitrag von jackDuijf »

Hallo,

Ich versuche Abbildung in List Und Label in eine Liste da zu geben.
Die Abbildung (Bitmap/Jpeg) komt aus einer Datenbank, und ist als Base64Encoded gespeichert.
Es gibt keine Datei die iregenwo abgelegt ist.

Ich habe versucht mit fieldtype LL_DRAWING und LL_DRAWING_HBITMAP.
Im designer wirdt angezeigt das es abbilding betrifft, aber die abbildung ist unsichtbar.

Dann habe ich ein Bericht zu Combit geschickt, incl. log Dateien von dem Designer un den Ausdruck.
Da kam die Antwort.....

Code: Alles auswählen

Dear Jack,

Thank you for your patience.
After analysis of your files by our development department, I would like to pass on the following findings to you: 
Unfortunately, the conversion will not work for XBase++. Unfortunately, you will have to create a corresponding conversion yourself. 
The corresponding .NET code would then look like this:


========================================================================================================================
        /// <summary>
        /// Tries to convert the passed string to an image using Base64 decoding
        /// </summary>
        /// <param name="content">The string to convert</param>
        /// <returns>Resulting image or null if the string could not be decoded.</returns>
        protected Image GetImageFromBase64(string content)
        {
            // Some speedy sanity check. As content is either a path or a valid Base64 image, we check for \ as shortcut as well.
            if(content == null || content.Length == 0 || content.Length % 4 != 0
            || content.Contains("\\"))
                return null;

            byte[] bytes = null;
            try
            {
                bytes = Convert.FromBase64String(content);

                Image image;
                MemoryStream ms = new MemoryStream(bytes);
                image = Image.FromStream(ms);

                // do _not_ dispose the stream for Bitmaps, see https://stackoverflow.com/questions/336387/image-save-throws-a-gdi-exception-because-the-memory-stream-is-closed
                if (!(image is Bitmap))
                {                    
                    ms.Dispose();
                }
                return image;
            }
            catch (Exception ex)
            {
                // a FormatException would be expected for invalid Base64 strings
                if (!(ex is FormatException))
                {
                    LoggingHelper.LogExceptionDetails(ex);
                }
                return null;
            }
        }

========================================================================================================================
You would have to implement such a function in Xbase++, and then pass the handle to the image (or a temporary path).
If you have any further questions left, please don't hesitate to ask.
Nun bin ich unbekannt mit .NET.
Ist da jemand in diesen Forum der behilflich sein kan mit das übersetzen von diesen code zu Xbase++

M.fr.gr,
Jack Duijf
Benutzeravatar
Wolfgang Ciriack
Der Entwickler von "Deep Thought"
Der Entwickler von "Deep Thought"
Beiträge: 2932
Registriert: Sa, 24. Sep 2005 9:37
Wohnort: Berlin
Hat sich bedankt: 13 Mal
Danksagung erhalten: 34 Mal
Kontaktdaten:

Re: Ausdruck von Base64Encoded Bilder

Beitrag von Wolfgang Ciriack »

Hallo Jack,

du solltest eigentlich mit Base642Bin() die Daten in eine für L&L lesbare Form umsetzen können.
z.B. StrFile(Base642Bin(<64Bindata>), "Test.jpg")
Viele Grüße
Wolfgang
Antworten