realbasic-nug
[Top] [All Lists]

Re: DecodeBase64 problem

To: Igy Castrillo <igy dot castrillo at gmail dot com>, REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: DecodeBase64 problem
From: Phil Mobley <phil at mobleybros dot com>
Date: Thu, 30 Sep 2004 08:10:16 -0700
Cc:
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20040929220700 dot 0C6CB4A1D5B at lists dot realsoftware dot com> <665df4d704093003386825ee68 at mail dot gmail dot com>
On Sep 30, 2004, at 3:38 AM, Igy Castrillo wrote:

Hello everyone.

This is probably an old topic -- my apologies. I've finally managed to EncodeBase64 my JPEG, GIF & other graphic files, convert them to strings and store them as blobs in my MySQL and RB databases. Unfortunately, I can't figure out how to convert the Base64 decoded binaries back to picture format so they can be displayed in my RB front-end. The RB Language Reference & User's Guide doesn't really help (no luck in the net either).

You could also do it this way:

1. Open the image as a Picture so that it is a standard RB Picture object. 2. Get the Width, Height, Color Mode and other properties that you are concerned with. 3. Use RGBSurface to loop through all of the pixels and store it in a memoryblock.
4.  Do the same for Mask.
5. Combine them into one big memoryblock in a specific order (protocol) of your choosing.
6.  Convert the Memoryblock to Base64.
7.  Save in the database.

To read it out of the database, you would just reverse the process.

The disadvantage with this method is that you are not able to take advantage of any compression (unless you added that to the image stream as well) -- so JPG files will be much larger (especially after the Base64 encoding).

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>