create program to create bitmap

Game development specific discussions.
Post Reply
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

thesanman112 wrote:just to be clear...hehehe...

if you take 255255255 and convert to base128 using ansii, the LENGTH of string will definitely be 4 digits...or is it 5, 128x128x128x128=268435456, makes sence to me! each value of 128 can be defined by an ansii character set.
yes... but your conversion to a decimal number can lead to misunderstandings.... perhaps it is better to think of everything in bits to actually see what is going on:

255-255-255 is actually 3 x 8 bit bytes or 24 bits...
an ascii character using Base128 can hold up to 7 bits...
so it will take 4 ascii characters, using base128, to represent 3 x 8 bit bytes (or, a 24 bit RGB value)
hexadecimal holds 4 bits per digit, so to represent 3 x 8 bit bytes it will take 6 hex digits (24 / 4 = 6 ) to do so....
thesanman112
Posts: 538
Joined: Jul 15, 2005 4:13

Re: create program to create bitmap

Post by thesanman112 »

there shouldn't be any misunderstanding, we are not doing anything to the number other than translating it to another language sort of speak, we cant perform any mathematical operation to it because the value would change, as long as the value remains STATIC, then translate away.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

thesanman112 wrote:there shouldn't be any misunderstanding, we are not doing anything to the number other than translating it to another language sort of speak, we cant perform any mathematical operation to it because the value would change, as long as the value remains STATIC, then translate away.
yup
thesanman112
Posts: 538
Joined: Jul 15, 2005 4:13

Re: create program to create bitmap

Post by thesanman112 »

the post of dodicats that you responded EXACTLY...thats the way to do it. I have been studying the code and it should work, even if code cant be translated to forum, you could always just use a smaller characterset and base to match that would transfer to forum without problems. ANd it will still be smaller than hex...Hmmm...base64?
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

thesanman112 wrote:the post of dodicats that you responded EXACTLY...thats the way to do it. I have been studying the code and it should work, even if code cant be translated to forum, you could always just use a smaller characterset and base to match that would transfer to forum without problems. ANd it will still be smaller than hex...Hmmm...base64?
no, base128 works best and is most effective... dodicats method will probably work...

The reason I responded with 'exactly' is because finally someone was seeing the advantages of using base128 which I had been posting about before that... I hadn't yet, and haven't yet, actually looked at his code to see how he converted to base128...
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: create program to create bitmap

Post by MrSwiss »

Just to catch up on things ...
The question about Integer size: FBC 32 = Integer = Long = 4 Byte, FBC 64 = Integer = LongInt = 8 Byte.
In other words: a (U)Integer always has the size of a Pointer (Any Ptr), which depends on the "bitness"
of the Compiler used.

One of the reasons, I'm against "indiscriminate" use of Integer, by most people here. Reason seems to
be: because of to many "old" examples in Doc, even using: UInteger as Color (instead of ULong), which
wastes 4 Bytes per instance, for absolutely no benefit at all, in FBC 64 (is OK on FBC 32), but should
be avoided, in order to "produce" code, usable with both compilers (without any changes required).

Not to long ago, FBC was 32 bit only (therefore, people have to adapt, by learning those facts).
Another fact is (pet subject of mine): most code (80-90%) can be written, using UNsigned data-types
exclusively. Example (tested with dodicat, many tries): fastest For loop-counter = UInteger (32/64).
Exception: can't be used on down counting loops, to or below "Zero/Null", all else is fine. Since most
For loops are up counting anyway (in BASIC that is), all is well.
ASM is different, loops usually go down to zero, for speed reasons (check on zero processor flag only).

@leopardpm, a little BMP in code, for your RLE compression routines (should give good results):

Code: Select all

' MakeColor_64x64.bmp.bas -- 2017-05-29, by MrSwiss

Const As ULong  scrw=640, scrh=480, iw=scrw-1, ih=scrh-1    ' screen stuff
Const As ULong  black=&hFF000000, white=&hFFFFFFFF, red=&hFFFF0000, orange=&hFFFF7F00, _
                yellow=&hFFFFFF00, green=&hFF00FF00, blue=&hFF0000FF, m_pink=&h00FF00FF, _
                violett=&hFF7F007F, cyan=&hFF007FFF, grey=&hFF7F7F7F    ' colors

' ===== MAIN =====
ScreenRes(scrw, scrh, 32, 2)
ScreenSet(1, 0)
Width scrw\8, scrh\16

Dim As Any Ptr img = ImageCreate(64, 64, grey, 32)  ' background grey (not seen!)

Line img, ( 0,  0)-Step(63, 63), red, BF
Line img, ( 5,  5)-Step(58, 58), orange, BF
Line img, (10, 10)-Step(53, 53), yellow, BF
Line img, (15, 15)-Step(48, 48), green, BF
Line img, (20, 20)-Step(43, 43), cyan, BF
Line img, (25, 25)-Step(38, 38), blue, BF
Line img, (30, 30)-Step(33, 33), violett, BF
Line img, (35, 35)-Step(28, 28), black, BF
Line img, (40, 40)-Step(23, 23), white, BF
Line img, (45, 45)-Step(18, 18), m_pink, BF   ' overwrites gray!

For i As UInteger = 0 To 5          ' just for fun ...
    Var x = i*90+60, y = i*30+100   ' calc. top/left pos. of img
    Put (x, y), img, Alpha          ' m_pink is 'transparent' alpha=&h00
Next
Flip

BSave("Color_64x64.bmp", img)   ' comment out, if BMP is saved once!
ImageDestroy(img) : img = 0

Sleep
' ===== END-MAIN =====  ' ----- EOF -----
A lot of: same color in lines, etc.
Size of code: 1,31 KB (on disk), BMP size ~20 KB, 64x64 Pixels ... enjoy. ;-)
BasicCoder2
Posts: 3955
Joined: Jan 01, 2009 7:03
Location: Australia

Re: create program to create bitmap

Post by BasicCoder2 »

This is a sort of pictorial messing about with what I think dodicat was probably doing.
Imagine a row of random rgb pixels shown by the program when run as colored blocks with their red, green and blue values listed below them.
Three numbers for each pixel making 3x4=12 numbers.
The row is treated as just one long binary number which is segmented into 7 bit groups for conversion to a string of characters.
The value of each 7 bit group is treated as an ascii code number 0 to 127 with 32 added so 0000000 would be the ascii code for a space character.
The resulting ascii string is shown as the resulting text data of the pixel row.
That concludes the coding of the row of pixels to a character string.

Now to reconstruct the actual pixel values from that row of characters they are converted back to a row of binary numbers which are then grouped into eight binary digits that will represent the actual rgb pixel values which when extracted and printed you will see are the same as the input values we began with.

Now as an experiment change const BITSIZE = 7 to const BITSIZE = 4

This is the same as using hexadecimal coding except the characters used are different from 0 to 9 and A to F

Note: the code below does have a bug in it to something to do with padding zeros I think which I haven't worked out a fix for yet, if ever.

.

Code: Select all

screenres 1290,480,32

const PIXELS = 4
const BITSIZE = 7  ' <--  CHANGE THIS TO 4 TO SEE A HEXDECIMAL RESULT

dim as ulong r(0 to PIXELS-1)
dim as ulong g(0 to PIXELS-1)
dim as ulong b(0 to PIXELS-1)


'get a row of 3 random pixel values
for i as integer = 0 to PIXELS-1
    r(i) = int(rnd(1)*256)
    g(i) = int(rnd(1)*256)
    b(i) = int(rnd(1)*256)
    line (i*32,0)-(i*32+31,32),rgb(r(i),g(i),b(i)),bf
next i

locate 6,1

'print the numbers
for i as integer = 0 to PIXELS-1
    print r(i)
    print g(i)
    print b(i)
next i
print

'now convert to one long binary number
dim as string tempString
dim as string bigString
for i as integer = 0 to PIXELS-1       'for each pixel value
    tempString = bin(r(i))
    while len(tempString)<8
        tempString = "0" + tempString 'insert leading zero
    wend
    color rgb(255,0,0)
    print tempString;" ";
    bigString = bigString + tempString
    tempString = bin(g(i))
    while len(tempString)<8
        tempString = "0" + tempString 'insert leading zero
    wend
    color rgb(0,255,0)
    print tempString;" ";
    bigString = bigString + tempString
    tempString = bin(b(i))
    while len(tempString)<8
        tempString = "0" + tempString 'insert leading zero
    wend
    color rgb(0,0,255)
    print tempString;" ";
    bigString = bigString + tempString
next i
print
'pad binary if not long enough
bigString = bigString + string(7-(len(bigString) mod 7),"0")

print
color rgb(255,255,255)
print

dim as string chars
chars = ""

dim as integer num
tempString = ""
for p as integer = 1 to len(bigString) step BITSIZE  'not 8 bits
    tempString = mid(bigString,p,BITSIZE)
    print tempString;" ";
    num = val("&B"+tempString)
    chars = chars + chr(num+32)
next p
print:print
color rgb(255,255,255)
print
print "string data = ";chars
print

color rgb(0,255,0)


print

'now convert back
'convert chars into string of binary digits
bigString = ""   'store result here
tempString = ""
for p as integer = 1 to len(chars)
    num = asc(mid(chars,p,1))-32
    tempString = ""
    tempString = bin(num)
    while len(tempString)<BITSIZE
        tempString= "0"+ tempString  'insert leading zero
    wend
    'print tempString;" ";
    bigString = bigString + tempString
next p

print
'print bigString
color rgb(255,255,255)
print
color rgb(255,0,255)
for p as integer = 1 to len(bigString) step 8  'now 8 bits
    tempString = mid(bigString,p,8)
    'print tempString;" ";
    num = val("&B"+tempString)
    print num;" "
next p

print

sleep

BasicCoder2
Posts: 3955
Joined: Jan 01, 2009 7:03
Location: Australia

Re: create program to create bitmap

Post by BasicCoder2 »

My thoughts on all this are that any image coded this way to fit the character limit of a forum post will still be a small image even if larger image than the obvious use of hexadecimal numbers would enable. It will however be better than using a palette when there are say more than 64 colors.
.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

MrSwiss wrote:@leopardpm, a little BMP in code, for your RLE compression routines (should give good results)A lot of: same color in lines, etc.
Size of code: 1,31 KB (on disk), BMP size ~20 KB, 64x64 Pixels ... enjoy. ;-)
ah ha, I detect a little challenge... I haven't been coding, just posting thoughts, because I haven't had any significant blocks of time... but will do!

I have been thinking about some different ways to RLE that might be better for sprite type of images, I will see if I can incorporate these for comparison.

BTW: the BMP it takes up 16kb on disk, uncompressed - the file size 'says' 20k because the minimum disk sector size... you can do it by math too: 64pix x 64pix x 4 bytes each(RGBA) = 16,384 bytes
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: create program to create bitmap

Post by MrSwiss »

leopardpm wrote:16,384 bytes
Not quite, you are forgetting the sizable Header of BMP.
leopardpm wrote:ah ha, I detect a little challenge...
Yep, as they say: "put your money, where your mouth is" ;-)
I've done some more String testing on Forum:
seems, the Data-String can have any size, below the max. allowed (inside code tags).

UTF-8 increases the String size up to ~35%, bad news ... (from 21 KB to 32 KB).
This occurred mainly, when using Char's above 127 (haven't figured out the start yet).

Good news, on the other hand: tested with 20 KB String size ... no problem at all.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

The BMP header is rather small (I think under 32 bytes...) - I got the 16K figure directly from the file size by right clicking the BMP in windows and choosing 'properties'... it tells both the disk space and actual bytes in file....

just starting out on the program... loading BMP and beginning to analyze image only here - I am a slow programmer... this took me 45 minutes so far... lol:

Code: Select all

' first example test of combination palettizing and basic RLE
' coded by LeopardPM for our happy group on the FreeBasic Forum
' attempting to most efficiently transfer images via text through forum posts...
'
Const As ULong  scrw=640, scrh=480, iw=scrw-1, ih=scrh-1    ' screen stuff
Const As ULong  black=&hFF000000, white=&hFFFFFFFF, red=&hFFFF0000, orange=&hFFFF7F00, _
                yellow=&hFFFFFF00, green=&hFF00FF00, blue=&hFF0000FF, m_pink=&h00FF00FF, _
                violett=&hFF7F007F, cyan=&hFF007FFF, grey=&hFF7F7F7F    ' colors

Const NULL As Any Ptr = 0

Dim As Any Ptr img

Function bmp_load( ByRef filename As Const String ) As Any Ptr
    Dim As uInteger filenum, bmpwidth, bmpheight
    Dim As Any Ptr img
    '' open BMP file
        filenum = FreeFile()
        If Open( filename For Binary Access Read As #filenum ) <> 0 Then Return NULL
        '' retrieve BMP dimensions
            Get #filenum, 19, bmpwidth
            Get #filenum, 23, bmpheight
        Close #filenum
    '' create image with BMP dimensions
        img = ImageCreate( bmpwidth, Abs(bmpheight) )
        If img = NULL Then Return NULL
    '' load BMP file into image buffer
        If BLoad( filename, img ) <> 0 Then ImageDestroy( img ): Return NULL
        Return img
End Function


ScreenRes 640, 480, 32

' load the image
dim as string fname = "Color_64x64.bmp"
    img = bmp_load( fname )
    If img = NULL Then
        Print "Image failed to load" 
        sleep
        ImageDestroy( img )
        end
    end if
    
    print "Image Loaded: ";fname
    put (300,200),img,pset
    
' Analyze Image
    print "Analyzing image: "
    print
    dim as uinteger ImageWidth, ImageHeight, ImageBytesPerPixel, ImagePitch
    dim as any ptr ImageAddress

    If 0 <> ImageInfo( img, ImageWidth, ImageHeight, ImageBytesPerPixel, ImagePitch, ImageAddress ) Then
        Print "unable to retrieve image information."
        Sleep
        End
    End If
    print "       Width (";ImageWidth;")"
    print "      Height (";ImageHeight;")"
    print " Pixel Bytes (";ImageBytesPerPixel;")"
    print "       Pitch (";ImagePitch;")"
    print
    
    ' How many colors?
    dim as uinteger NumOfColors = 0, NumOfRuns = 0
    dim as uinteger PalCol(5000)   '<---- should be enough for most images...
    dim as uinteger PalNum(5000)   '<---- to make Color Histogram
    dim as uinteger RL1(5000)    '<---- to make RunLength Histogram
    
    For y As uInteger = 0 To ImageHeight - 1
        dim as uinteger TempColor
        Dim row As UInteger Ptr = ImageAddress + y * ImagePitch
        For x As uInteger = 0 To ImageWidth - 1
            TempColor = row[x]
            dim as uinteger ThisColor = 0
            if NumOfColors > 0 then
                for tc as uinteger = 1 to NumOfColors
                    if PalCol(tc) = TempColor then
                        ThisColor = tc
                        PalNum(tc) += 1  '<--- keep track of how many pixels have this color total, not run...
                    end if
                next tc
            end if
            if ThisColor = 0 then   ' if not found in palette, then add it
                NumOfColors += 1
                PalCol(NumOfColors) = TempColor
                PalNum(NumOfColors) = 1
            end if
        next x
    next y

' print out palette
    print "Number of Colors: (";NumOfColors;")"
    for x as uinteger = 1 to NumOfColors
        print using "(####)";x;
        select case ImageBytesPerPixel
            case 3
                print " - "; right("000000" + hex(PalCol(x)),6);
            case 4
                print " - "; right("00000000" + hex(PalCol(x)),8);
        end select
        print " qty:(";PalNum(x);")"
    next x


' end program and take out garbage...
    sleep
    ImageDestroy( img )
    end
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: create program to create bitmap

Post by MrSwiss »

@leopardpm,

went over your code and optimized or added some stuff.
Chopped lengthy If statements short, and all colors are now ULong (correct for 64 bit too):

Code: Select all

' first example test of combination palettizing and basic RLE
' coded by LeopardPM for our happy group on the FreeBasic Forum
' attempting to most efficiently transfer images via text through forum posts...

#Include "file.bi"
'
Const As ULong  scrw=640, scrh=480, iw=scrw-1, ih=scrh-1    ' screen stuff
Const As ULong  black=&hFF000000, white=&hFFFFFFFF, red=&hFFFF0000, orange=&hFFFF7F00, _
                yellow=&hFFFFFF00, green=&hFF00FF00, blue=&hFF0000FF, m_pink=&h00FF00FF, _
                violett=&hFF7F007F, cyan=&hFF007FFF, grey=&hFF7F7F7F    ' colors

Const NULL As Any Ptr = 0

Dim As Any Ptr img

Function bmp_load( ByRef filename As Const String ) As Any Ptr
    Dim As ULong    filenum, bmpwidth, bmpheight    ' BMP header definition
    Dim As Any Ptr  img
    
    If FileExists( filename ) Then  ' added check (needs "file.bi")
        '' open BMP file
        filenum = FreeFile()
        If Open ( filename For Binary Access Read As #filenum ) Then Return NULL
        '' retrieve BMP dimensions
        Get #filenum, 19, bmpwidth
        Get #filenum, 23, bmpheight
        Close #filenum
        '' create image with BMP dimensions
        img = ImageCreate( bmpwidth, bmpheight,, 32 )   ' no abs() needed is unsigned
        If img = NULL Then Return NULL                  ' added depth
        '' load BMP file into image buffer
        If BLoad( filename, img ) Then ImageDestroy( img ) : Return NULL
    Else
        Return NULL
    End If

    Return img
End Function


ScreenRes(scrw, scrh, 32)

' load the image
dim as string fname = "Color_64x64.bmp"

Width scrw\8, scrh\16   ' larger Font

img = bmp_load( fname )
If img = NULL Then Print "Image failed to load" : Sleep : End
Print "Image Loaded: ";fname
put (300,200),img,Alpha ' want to see "transparent"

' Analyze Image
print "Analyzing image: "
print
dim as uinteger ImageWidth, ImageHeight, ImageBytesPerPixel, ImagePitch
dim as any ptr ImageAddress

If ImageInfo( img, ImageWidth, ImageHeight, ImageBytesPerPixel, ImagePitch, ImageAddress ) Then
    Print "unable to retrieve image information." : Sleep : End
End If

print "       Width (";ImageWidth;")"
print "      Height (";ImageHeight;")"
print " Pixel Bytes (";ImageBytesPerPixel;")"
print "       Pitch (";ImagePitch;")"
print

' How many colors?
dim as ULong NumOfColors = 0, NumOfRuns = 0
dim as ULong PalCol(5000)   '<---- should be enough for most images...
dim as ULong PalNum(5000)   '<---- to make Color Histogram
dim as ULong RL1(5000)    '<---- to make RunLength Histogram

For y As uInteger = 0 To ImageHeight - 1
    dim as ULong TempColor ' never 64bit always 32bit
    Dim row As Ulong Ptr = ImageAddress + y * ImagePitch ' never 64bit always 32bit
    For x As uInteger = 0 To ImageWidth - 1
        TempColor = row[x]
        dim as ULong ThisColor = 0 ' never 64bit always 32bit
        if NumOfColors > 0 then
            for tc as uinteger = 1 to NumOfColors
                if PalCol(tc) = TempColor then
                    ThisColor = tc
                    PalNum(tc) += 1  '<--- keep track of how many pixels have this color total, not run...
                end if
            next tc
        end if
        if ThisColor = 0 then   ' if not found in palette, then add it
            NumOfColors += 1
            PalCol(NumOfColors) = TempColor
            PalNum(NumOfColors) = 1
        end if
    next x
next y

' print out palette
print "Number of Colors: (";NumOfColors;")"
for x as uinteger = 1 to NumOfColors
    print using "(####)";x;
    select case ImageBytesPerPixel
        case 3
            print " - "; right("000000" + hex(PalCol(x)),6);
        case 4
            print " - "; right("00000000" + hex(PalCol(x)),8);
    end select
    print " qty:(";PalNum(x);")"
next x

' end program and take out garbage...
sleep
ImageDestroy( img )
End
BMP_file_format Wikipedia, FYI.
Last edited by MrSwiss on May 30, 2017 16:56, edited 1 time in total.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

MrSwiss wrote:@leopardpm,

went over your code and optimized or added some stuff.
I always appreciate your help, Mr. Swiss... but you might want to wait until it is at least doing something interesting because I have already coded more with the program 'the old way' and I would have to re-fix all you have done to the previous version.... a somewhat completed version should be ready later on today for you to do your thing to it! Just don't want you spending time re-doing stuff...
BasicCoder2
Posts: 3955
Joined: Jan 01, 2009 7:03
Location: Australia

Re: create program to create bitmap

Post by BasicCoder2 »

Run length encoding may work well where there are many runs of the same sequence but is that the case with the parrot image?
The program below will create a png version of dodicat's parrot.
Haven't counted the number of characters so I can't compare it with a pure hexadecimal version.

Code: Select all

dim as integer buffer(1173)
dim as integer i

i = 0
read buffer(i)
print i;buffer(i)
while buffer(i)<> 0
    i = i + 1
    read buffer(i)
    print i;buffer(i)
wend

sleep

dim as integer f
f = FreeFile
Open "bird222.png" For Binary As #f
' Write the array into the file, using file number "f"
' starting at the beginning of the file (1).
Put #f, 1, buffer()
Close #f
print "DONE"
sleep

DATA  1196314761, 169478669, 218103808, 1380206665, 1342177280, 1006632960, 776,-839268864, 50331838, 1414287360, 16777797
DATA -1218211664,-1699125867, 1451073641,-1371183212,-2120065141, 1602725979,-1006257156,-1225625435, 1468245763,-519852052,-2035613281
DATA  1906491482,-1135641946, 118190748, 163773969,-1185515111,-2001703009, 1248696153,-398236791,-1614806617, 44626027,-1368812876
DATA  1889357953, 1231522892, 690631226, 270018853, 78640668,-1689029740, 218910838, 60282908, 1548709008, 977551697, 1400414006
DATA  558855073, 573578805, 96335126,-771522620,-970587508, 1603187648, 1633386396, 708070239, 78904367, 394839519,-903410423
DATA -1126442803, 621258722,-1261258818, 1974126710, 1041734246,-1758660890, 2091960978,-1016030797,-550239349,-1881539861, 1548904302
DATA -270141206,-1915359287,-1166694717, 926444950, 943672640, 1511160931,-1327689332, 94170629, 1004989504,-1144477005,-2137746015
DATA  607931470, 421407807, 61004069,-1632644658,-1058502237, 2076039803, 928870512, 1518159993,-674222281, 497726757,-1809416573
DATA  1771416698,-27805086,-1613691190,-168141051, 970844257,-379927345,-1312374338, 1150463147,-1110209374,-2050299002, 594903943
DATA -1447137925, 798768234,-48279751, 388044745, 162188812,-1077877281,-1220370231,-2000005490,-1065375061, 2074632087, 759317850
DATA  320303175,-1781788640,-34321661,-21183679,-615074573, 1685289630, 1163950465,-1335009358, 796743217,-1073177941,-599652708
DATA -1548990250, 899529516,-1430152281, 2040510864, 1514846586,-973849176, 62711818, 1151198204,-1580368494, 1705259630, 908763765
DATA  1548757348, 277182743,-1308324687,-59374730,-907983372, 867356639,-1536774973,-2000842606, 1099353851,-1952020860, 1634340712
DATA -1269849541,-1373593925,-1850034278,-2122409559,-1919857050, 121254156, 2077679147,-846215946,-1446949974, 1034211396, 1956672100
DATA  780761925,-1642346534, 2035356825, 2058562831,-1837718696,-864457075, 1690984043, 557954719,-1939392416, 397262900,-169742698
DATA -965288711,-1197199174,-141247063,-1083797020,-2018890096, 1249555129, 2123199664, 1486463077,-1756083649,-1652470178, 765632074
DATA -1406297005, 1784618410, 221402904,-619922226,-322775345,-943042356, 1434637161,-1198032757, 884651872,-1810471565, 1498639314
DATA  1436376670,-284394604,-1857042968, 2021485467,-630022026, 1499685804, 73107987, 1654777193, 1654615990, 1216648286,-1018831928
DATA  1957808328, 629581644,-1648439400,-223267490, 427113328, 251658431, 1094994190,-1396484012, 309060050, 1908874353, 578403279
DATA -776965246, 2023662480, 1626627088,-1541881365,-591065570, 1202422977,-2108583791, 1162240211,-1375154988,-1308115955,-1302798006
DATA -1041032896,-1306816022,-127713120, 407014240, 1619890811, 1032521487, 1944010378, 1866497860, 1578121456, 1735884412,-63311879
DATA  242245886,-1285187507,-1137415975,-1027205013,-320792257, 1064819780, 1920316863,-195005582, 1943125862,-676270242,-783335957
DATA  1633942813,-2025742787, 1159139913,-1137149195, 830499771, 1504353658,-571878489,-1795967107,-639534277,-588643857, 865714408
DATA -1670265694, 396528164, 1524376333, 434842796, 2053673484, 683684065, 2052524937, 1110076093,-1252764843,-1229344326, 1994896310
DATA  274649019, 1995295045, 388930874,-1408087769,-2107171714, 110795806, 842286018, 999233644, 1183206673, 1825876329, 1990225158
DATA  980802487, 1707838701, 1841748403, 1909401398, 781697987, 612441241,-1098646706,-347592200, 1591985858,-1423143417, 308578994
DATA  1730031169,-758523338,-1021623266,-1944026576,-1040139377,-410109789, 302189613, 1880084879, 61824674, 695957044, 959763789
DATA  678611748,-980725228, 470902362,-478616075,-1200065096, 1443374774, 403723691,-1848520901, 525460489,-973608828,-376507165
DATA -350927168, 51258312,-1716688245,-977353319,-521249595, 47554784,-332881351, 579455017, 1685350468,-1576006970, 1586563107
DATA -1084605068,-433936978, 1758738744, 184773288, 1293923691, 1859650540, 1690917559, 1435759785,-2139551506,-501053320, 935248207
DATA  836792802,-488184070, 2070179383, 621630421,-1555658478,-757748072, 1933154863, 143211358, 555309804, 1995233487, 1361352606
DATA  13138402,-465301031, 1444995272, 1151269150, 1431392484, 1692718099,-1506897630, 325491083,-1265749797, 1586678111,-401678626
DATA  499839903, 1049334912,-2097259488, 1587315236,-774177186,-437991244,-124561359,-1537235571,-1404185769,-42855381,-1364007575
DATA  743085547, 1677912400, 1334119532, 10294472,-404664837,-560047591, 889588673,-1750167290, 783200087,-405811539, 307238334
DATA  515531030,-1127428728, 1109926141,-769528833, 538972430, 282727836, 533380811,-398111907, 457278620, 1784431435,-2049190090
DATA  2037547970,-195705185,-2011815854,-1287750531, 336957682,-2062235032, 1537864881,-2023109008,-347193629, 1731716208, 13744437
DATA -1149145466,-53215499,-407398443,-351637645, 532657253, 418645160, 1954110413, 569892593,-1695215409, 722752154,-1310589774
DATA -2003614866,-612353821,-1699571574,-1892580390,-1655631995,-1904937831, 910334325,-1395838706, 472409019,-346968796,-312723410
DATA  548906529, 1932042992, 75968593, 1842381497, 1655440336, 73417766, 924750515, 1177225858, 794177349,-365429254, 525847291
DATA -268451906, 2069118975, 969999361, 571404968, 168625583,-752467831,-95669115, 820935164, 1916825440,-2139028807,-431365525
DATA  1330433206, 1090478759, 33161453,-232767317,-271841196, 1941530991,-1001865200,-1936832239,-1183603124, 6088540, 225483291
DATA -555879903, 1285100477, 1611479857,-1037615788,-184427836,-234524708, 343767764,-1478139202,-600941573, 1690255473, 959592562
DATA  1987528793, 1682843142, 777953438, 132039256,-1147187481,-430050563, 1318037085,-508308527, 1033115570,-1221150994, 1441611899
DATA  659428419,-169094124,-193366742, 1266084872, 1425569906,-171277798,-356517897,-1514342107,-1691143366, 1094265280,-2046199077
DATA -345787486,-957254477,-1026120904,-633245814,-9823792,-794657917,-925765903,-1282505738,-824589691, 536478969,-921646620
DATA  482153167,-989558706, 332086384, 1856457868,-1718539823, 1382489881, 1521940273, 1890940280, 433089147,-1204465886,-1747772878
DATA  574912159,-1759427895, 209912707, 373171717, 814190949, 631755745, 1632652321,-2130177122,-1297871543, 850744419,-376682146
DATA  1842722794, 245936344, 987831677, 879383594,-216646737, 1896938302,-2098656476, 2046158955,-671894072,-1401833794,-1636005596
DATA  282139104,-994569706, 407986443, 1755804523, 1441882058,-682535637,-1386508520,-118485546,-1118821610,-850566800,-1896153058
DATA  1723905593,-313577913, 892699099, 1099078553, 175376364,-531782927,-418882472,-910084551, 128209676,-1347201966, 754578402
DATA -478319979,-1161385105, 1369871738,-372005033, 1024479252,-420713116,-456716591,-1443290232,-1455309893, 811098932,-1711670248
DATA -956034294,-1305961391, 689258796,-980704630,-647126338,-288383182,-1783997901, 1299176794,-1498726372, 1141797297,-137056461
DATA -1585988563,-1058442813,-575165968, 1264621307, 1098238668, 2012705644, 1768170886,-991919709,-1474133436,-879885801, 1632352857
DATA  18494826, 744468868,-1696405290, 1810869205,-2129506252, 84362784, 1228127725,-237833657, 872525639, 545698203, 156235620
DATA -252381961, 917685380,-1832378052, 1768409677, 1567352010, 1657799275, 1525013424,-1371779763, 1082646193, 224298313,-1968396945
DATA  645282542,-1342576014, 716087243,-1512908651, 845879704, 2113003119, 1669500020, 841077003, 1496900396, 1832161578, 1189943379
DATA -244398701,-544548861,-1373943894,-1589310457, 1165457538, 132884899, 2120056710,-909446916,-2035889435, 1649019910,-272826549
DATA  1129878250, 940650007, 254120142,-1293874711,-169442995, 1512049691, 1970142860, 207105536, 1817971224,-324769804,-1875317780
DATA -1434914052, 314146237,-991099731, 593942972,-1706523554, 595751361,-741896375,-617100741,-1496488464, 1074110294,-1762826858
DATA  1457550101,-601985379, 1506739433, 2050889182,-1449668367, 1257106859, 429404856,-1120467446, 753485543,-1862994359, 1256157093
DATA  522800933,-2055278326, 912827613, 1058024922, 1798052558, 1140976362,-1208468254, 1234008841, 14879786,-649581442, 1242255601
DATA -1684775624, 1625461788, 1050854950, 766340176,-1600812495,-927460075, 1144280154, 1851994929, 780701910,-1423370982, 1966256684
DATA  1798743397,-1420370535,-691294874, 1567350141,-914754090, 1098514266, 1593244735, 800912286, 1554818624,-798694093, 1566177526
DATA  1130843421, 590046336,-73018353,-1115926689,-755703169,-56743703,-1014206763,-371942447,-1873768850, 1330595886,-1085788325
DATA  1964189749,-2089745959, 543310598,-1356105700, 1070517019, 159624428,-1793692125,-962004719,-1657880666, 578764728,-1745246856
DATA -571287747,-1182559080,-1061327355, 195301924, 42643541,-1078415875, 1947357792,-913245716, 956135411, 1776516816, 548154727
DATA -1716106990, 1635842154,-73059760,-762260895,-704846084,-1509487076,-1520168277,-1121315799,-1554313790, 858934226, 15820643
DATA  939583672, 1462470927,-2057946786,-1684591040, 303137485, 559019268, 802114869,-453954939, 1050659919, 1911093693, 1392838421
DATA  161928120, 1518168596,-1367530858, 691945290, 829956211, 1441111568,-1214373645,-1294309926, 541826471, 640437044,-812660172
DATA -849332517,-219767047,-622358682, 84241361,-1860430637,-1420680108,-2056387117,-1541953463, 478315691,-767403423, 220598751
DATA -2121478966, 1807636139, 494294175, 1849692298, 874974001,-1669330758, 1443605433,-425837448,-2102014206,-1709899259,-677034959
DATA -358448117,-1591956308, 852838192, 1548901752,-520253412, 944636988,-1111965992,-853064965,-1708154139, 264956966,-1454229477
DATA -1967035088,-268106475, 1453344573,-721379213, 1598202150, 1315859773,-585065898,-1926116060,-433061713, 809576037, 1950002660
DATA  520225010, 221831638,-488258853, 45975270,-368299760,-1663668637, 1410008554, 222761250,-1978357487, 1533065101, 1934992414
DATA -59430332,-1083074456,-669308137,-1777108587, 976399343, 824958430,-1500826605, 1695362137, 1936502222,-1315937973, 410017904
DATA  262445446, 676346910,-1936068578, 1436562403,-1263504781, 327369092,-1979072410,-667391936,-2007959580, 871339847,-2067894502
DATA -533699122,-1157201864,-690628803,-1979792090,-912517038,-57579475, 1418798844,-1658970604,-1553451880, 416851024, 1890465855
DATA -1465782038, 1881360302, 1798680266,-136536714,-1179117528,-994074909, 1640214380,-31126251, 920573788, 990091945,-795273941
DATA -681654257, 1693395945,-1448646596,-2021029623, 768981359,-1938628217,-1471033010, 566281441, 988563051, 1812869889,-1209674790
DATA  1812249979, 1606528331,-1082565741, 282747789, 948228235,-1560859757,-1781444235,-1664114887,-1000153967,-1485648993, 10239517
DATA -1027417993, 699939010,-219758395,-1965352462, 1804425014,-961054273,-644791906, 1243319812,-1020609942,-10261139, 1093937221
DATA -277300529,-1062036530, 1047766502,-1924563161, 521709663, 1747402951,-1027415614,-1301789564,-2144637936,-1422956601, 2111596314
DATA  564975543, 1075604720,-640201345, 1331120842,-879993250, 497092739,-856261540,-626518446, 2134205820, 1634679905, 711358666
DATA  333699036,-1914600256, 1879461449,-721847995, 422032355, 2066573719, 1292168570,-2144029213, 724786605, 134108879,-351991578
DATA  1928836979,-1895621957, 1419674910, 362410487, 409405717, 1494376882, 217166058, 284170489,-54755752,-949632522,-1688529238
DATA  1077271694, 160084513,-1108391603, 472883030,-1156978194,-346271502,-1611957931, 1507229567, 1074637659, 1461414277,-1726847501
DATA -2083743844, 1672078408, 963803390,-237735818, 2121176979,-1245857414, 1858516395, 225470678, 1780217929,-806622614,-1961442566
DATA -1316557723, 1490492546,-552600863,-1758567703,-1274405419, 767997255,-1768621011, 345281764, 642526334, 532539512, 1207287382
DATA  132879825,-662840081,-1682448167,-2079271871,-1499356754, 1828142773, 1863193304,-327798568,-1179730468, 1509515215, 803280112
DATA -772971235, 1969278675, 1598769759,-467688438,-533551323,-1672114438,-1171641816, 1866657906,-672710243, 913755240, 274632777
DATA -189936639, 90239877,-274729123,-777339403, 1567905968,-323246691,-369822636, 572021736, 367071754,-1893997037, 1262851008
DATA -1103815029,-497430340,-1314886857, 613509018,-371856421, 32238426,-363808268,-708280993, 1906609301,-93270340, 599483209
DATA  1511709306, 337674960,-1815510284, 801162327,-1237116305, 1033850771,-1064385548, 1219694866,-396015311,-1349754830, 2096658414
DATA -70595906,-338749171, 1884915417, 998796280,-1177808714, 1860966857,-1813419031, 1663664289, 1416046722, 443506772,-325106465
DATA -1585496980, 1082238052, 159065725, 1087973143,-690045574,-1953591594, 1472028478, 879266071, 1094068515, 568142954,-455388793
DATA -72652148, 1234599334,-1958412208, 691865144,-208797105,-2091143489, 528137067, 1934098902, 1076117899,-10568540, 997702589
DATA  1366586926,-1692138320,-2113293468,-1266371043,-910978943, 668433258, 337145859, 1673675937,-2055073502, 501155502, 101557820
DATA  416797935,-837371280, 1903259177,-1693026127, 1232808098, 1800892233,-1691181161, 377169101, 1423980233, 986848312, 1454192798
DATA  571253607, 426438465, 508328131, 715919496,-713376744, 595260792, 1981779604,-1968085224,-1840711647, 1340196270, 682061506
DATA -1568395496, 1426385970,-659429009,-1247332836, 1338563017, 582356993, 856949150, 1133636630, 232319291,-42180864, 1535560666
DATA -1928645038, 1780884880,-368940693,-1526791346, 107301492, 2091833226,-655052443, 1730580148,-1625730221,-1702487249,-1206574333
DATA -972377986, 2003481703, 1718096007, 829213107, 80779026, 1878264084, 323716252,-1476359003, 1970824948,-758150966,-1707445021
DATA  401790016,-1604171610,-471877316,-1052129695,-693444504, 2028854694, 1501579011,-1581050333, 759784626,-1312453746,-1092156450
DATA  1318355225, 1150149015,-2115494622,-1401202420, 1121938262, 961350846, 403211793,-389277990,-526566776, 1994202177, 923638587
DATA -1204801233,-1844961128,-1708903132,-1575844238, 980740691,-817924616, 1633268962,-531665509, 710811859, 1690312227,-1638092194
DATA  1431602952, 1519195168, 544018029,-1003034400, 453054528, 1762533961, 2138019856, 1197281570, 1969866127,-1727850622, 1336026656
DATA -200481661,-898643631, 1948592703, 9875310, 1224736768,-1371255227, 8544322, 0
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: create program to create bitmap

Post by leopardpm »

BasicCoder2 wrote:Run length encoding may work well where there are many runs of the same sequence but is that the case with the parrot image?
The program below will create a png version of dodicat's parrot.
Haven't counted the number of characters so I can't compare it with a pure hexadecimal version.
No, it doesn't work well with images which do not have same color pixels next to each other horizontally... in fact, RLE 'can' make a file bigger in such a case where most of the pixels are unique.

I haven't really looked close at the parrot image, but most 'pictures' are not good for RLE. BUT, when you do your 'lossy / reduced colors' thing to it, it might be a better candidate...

If we want to transfer both sprite type images (characters and terrain tiles etc), which are good for RLE, and transfer picture type images, then I suggest having at least two different ways of compressing them:

(1) Palettized and RLE for Sprites

(2) Some sort of Lossy for pictures
Post Reply