PNG to Base64 string
|
12-27-2018, 05:27 AM
Post: #4
|
|||
|
|||
RE: PNG to Base64 string
To demonstrate how a PNG to Base64 is decoded and then encoded, I'll use a basic block of 3 bytes of data expressed in decimal format as {137, 80, 78}.
Step 1: Convert these bytes to binary format using SETBASE({137,80,78},1). The result is {#10001001b,#1010000b,#1001110b} Step 2: Format as string, making sure each string is 8 chars long, left-padding with zeroes where required, resulting in: 10001001 01010000 01001110 Step 3: Combine and then break into 6-bit chunks: 100010010101000001001110 to 100010 010101 000001 001110 Step 4: Format as binary integers to get: {#100010b,#10101b,#1b,#1110b} Step 5: Format as decimal integers SETBASE({#100010b,#10101b,#1b,#1110b},3) to get: {#34d,#21d,#1d,#14d} Step6: Look up the nth character in the Base64 alphabet (see https://en.wikipedia.org/wiki/Base64) for each integer to get: iVBO And so you iterate over each three byte block to compile the string, and in the end deal with any fractional remainders. For anyone more familiar with these things; is there a quicker and simpler way to get from {137, 80, 78} to {34, 21, 1, 14} on the HP Prime? Any suggestions would be appreciated. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
PNG to Base64 string - Jacob Wall - 12-22-2018, 03:24 AM
RE: PNG to Base64 string - Jacob Wall - 12-22-2018, 08:30 PM
RE: PNG to Base64 string - Jacob Wall - 12-27-2018, 05:09 AM
RE: PNG to Base64 string - Jacob Wall - 12-27-2018 05:27 AM
RE: PNG to Base64 string - Didier Lachieze - 12-27-2018, 08:23 AM
RE: PNG to Base64 string - Jacob Wall - 12-27-2018, 06:47 PM
RE: PNG to Base64 string - ijabbott - 12-27-2018, 06:16 AM
RE: PNG to Base64 string - Jacob Wall - 12-27-2018, 06:35 PM
RE: PNG to Base64 string - chromos - 12-27-2018, 08:41 PM
|
User(s) browsing this thread: 1 Guest(s)