Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

script for decompressing bgf

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Wed Aug 12, 2015 1:22 pm    Post subject: script for decompressing bgf Reply with quote

Hi,

I use my own graficlib and use $inc and restore to set every pixel to display.

To save space, I want to use compressed images from bascom bgf tool. Has anybody write a script for decompress it? Are their any informations about the algo which is used for compression?

Cheers

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Aug 12, 2015 6:33 pm    Post subject: BGC file is RLE coded Reply with quote

Here is the routine AndersL / SIX1 / HKipnik wrote to decompress a BGF picture. Look at the &HAA 'repeat' token.

'BGC file is rle coded &HAA represents this, the byte after &HAA is the number of times that the byte before &HAA wil be repeated

Code:
Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy)
   Do
      Read Pixel                                            'Read the value for the pixel
      If Pixel = &HAA Then                                  'BGC file is lre coded &HAA represents this, the byte after &HAA is the number of times that the byte before &HAA wil be repeated
         Read Repeat                                        'Byte after &HAA contains the number of times to repeat
         Repeat = Repeat - 1
         For L = 1 To Repeat                                'Loop the repeat
            Call Ili9327_write_dataw(prevpixel)             'Write the pixel data to the display
            Decr Imagesize                                  'Decrease the bytes still to be processed
            Incr Xpos                                       'Incr the xpos
            If Xpos > Xsize Then                            'If the xpos is larger then xsize of the image start at a new y line
               Xpos = 1                                     'and set the xpos pos back to the first position on the new line
               Incr Ypos                                    'Start a new y line
               Tempx = Xpos + Xoffset                       'Pixel position is the image postion + the offset
               Tempy = Ypos + Yoffset
               Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy)
            'Print "tempx,tempy,tempx2,tempy " ; Tempx ; " " ; Tempy ; " " ; Tempx2 ; " " ; Tempy
            End If
         Next L                                             'Next repeat loop
      Else                                                  'It's a regular byte, not LRE encoded
         Pixelword = Rgb16(pixel)                           'Convert the 8bit pixel to 16bit pixel
         Call Ili9327_write_dataw(pixelword)                'Write the pixel data to the display
         Prevpixel = Pixelword                              'Store the pixel in a temp word, maybe we need it if the next byte is &HAA
         Decr Imagesize                                     'Decrease the bytes still to be processed
         Incr Xpos
         If Xpos > Xsize Then                               'If the xpos is larger then xsize of the image start at a new y line
            Xpos = 1                                        'and set the xpos pos back to the first position on the new line
            Incr Ypos
            Tempx = Xpos + Xoffset                          'Pixel position is the image postion + the offset
            Tempy = Ypos + Yoffset
            Call Ili9327_setxy_frame(tempx , Tempy , Tempx2 , Tempy)       'Start a new y line, send the xy position to the display
         'Print "tempx,tempy,tempx2,tempy " ; Tempx ; " " ; Tempy ; " " ; Tempx2 ; " " ; Tempy
         End If

      End If
   Loop Until Imagesize = 0  
 


Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 677

poland.gif
PostPosted: Wed Aug 12, 2015 7:17 pm    Post subject: Reply with quote

Here You can read some info http://wiki.mcselec.com/bavr/Tools_Graphic_Converter
You must also know that first two bytes in BGF contains information about height and width.
I also made small tool for convert BGF into BMP again if you don`t have sources (bmp) anymore. It can be useful Wink
http://bart-projects.cba.pl/enigma.html
Back to top
View user's profile Visit poster's website
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2108

netherlands.gif
PostPosted: Wed Aug 12, 2015 9:37 pm    Post subject: Re: BGC file is RLE coded Reply with quote

bzijlstra wrote:
Here is the routine AndersL / SIX1 / HKipnik wrote to decompress a BGF picture

99% procent of that code is taken from my ssd2119 routine Lcd_showpicture, published back October 2010.
http://evertdekker.com/wp/?p=257
Everything i have written and published is free for download and use, but it's not nice to see now that everybody except me gets the credits.

Edit: Made it already back in July 2009 for the Siemens S65 display
http://evertdekker.com/wp/?p=304

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Aug 12, 2015 10:08 pm    Post subject: Sorry Reply with quote

Evert

Sorry about that. Thanks for your code.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
boeseturbo

Bascom Member



Joined: 23 Jul 2007
Posts: 31

blank.gif
PostPosted: Thu Aug 13, 2015 8:58 am    Post subject: Reply with quote

thank you very very much!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum