LCDInfo.com

http://www.lcdinfo.com
It is currently Tue Dec 12, 2017 22:07

All times are UTC + 2 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Aug 10, 2004 14:16 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
I was asked how to make a plugin that uses bitmaps so here is a little example.

Code:
class Data : public DataSource
{
   virtual void __stdcall onCreate(void)
   {
      bmp = new LCDBitmap;
      bmp->create(128, 32);

      play_bmp = new LCDBitmap;
      play_bmp->load("play.bmp");

      addImage("WMP.spectrum", "Spectrum analyzer bars");
      addImage("WMP.scope", "Scope analyzer dots");

      addVar("WMP.title",         "Title",            VAR_STRING); // 0
      addVar("WMP.author",      "Author",            VAR_STRING); // 1
   }

   virtual void __stdcall onDestroy(void)
   {
      delete bmp;
      delete play_bmp;
   }

   
      /* for future LCDinfo version
      virtual int __stdcall configure(void)
   {
      return -1;
   }
                */

   virtual void __stdcall getValue(int varNo, Value value)
   {
   }

   virtual LCDBitmap* __stdcall getImage(int imageNo)
   {
      switch(imageNo)
      {
         case 0:   // spectrum analyzer
         {

            bmp->clear();

            for(int i=0;i<128;i++)         
               bmp->line(i, 31-ptr->spectrum[i]/2, i, 31, PIXEL_SET);

            //bmp->setPixel(2, 2, PIXEL_SET);

            return bmp;
         }

         case 1:   // scope analyzer
         {

            bmp->clear();

            for(int i=0;i<128;i++)         
               bmp->setPixel(i, 31-(MIN( (ptr->scope[i])/2, 31)), PIXEL_SET);
               
            //bmp->setPixel(2, 2, PIXEL_SET);

            return bmp;
         }

         default: return bmp;
      }   
   }

private:
   LCDBitmap *bmp;
      LCDBitmap *play_bmp;

};

static RegisterFactory<IPlugin, Plugin> plugin;
static RegisterFactory<IData, Data> data;


That should be some basics for making a plugin with bitmaps. Checking lcdbitmap.h in the SDK should reveal all the possibilities but some will be documented here soon.


Last edited by Henri on Tue Aug 10, 2004 14:37, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 14:36 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
So what you can do for LCDBitmap ? Here are some examples.

Code:
   /**
    * Create bitmap.
    *
    * Initialize bitmap and allocate memory.
    *
    */
   void create(int width, int height)

   /**
    * Clear bitmap.
    *
    * Clear bitmap picture data.
    *
    */
   void clear(void)

   /**
    * Load bitmap from disk to memory.
    *
    * @param filename name of bitmap file.
    * @return True if bitmap loaded ok, false otherwise.
    *
    * TODO: check palette for correct black/white order
    *
    */
   bool load(std::string filename)

   /**
    * Get width of bitmap.
    *
    * @return Width of bitmap.
    *
    */
   unsigned int width(void) const

   /**
    * Get height of bitmap.
    *
    * @return Height of bitmap.
    *
    */
   unsigned int height(void) const

   /**
    * Set individual bitmap pixel.
    *
    * @param x X position.
    * @param y Y position.
    * @param style What to do for pixel: PIXEL_SET, PIXEL_CLEAR
    *
    */
   void setPixel(unsigned int x, unsigned int y, PixelStyle style)

   /**
    * Check if defined pixel is set.
    *
    * @param x X position.
    * @param y Y position.
    * @return true if pixel is set, false if pixel is not set.
    *
    */
   bool getPixel(unsigned int x, unsigned int y)

   /**
    * Draw line.
    *
    * @param X1 Begin x position.
    * @param Y1 Begin y position.
    * @param X2 End x position.
    * @param Y2 End y position.
    */
   void line(unsigned int X1, unsigned int Y1, unsigned int X2, unsigned int Y2, PixelStyle style)

   /* midpoint circle algorithm */
   void circle(unsigned int xC, unsigned int yC, unsigned int radius, PixelStyle style)

   void box(unsigned int x, unsigned int y, unsigned int x2, unsigned int y2, PixelStyle style)

   /**
    * Fill area surrounded by pixels. Takes some pixel inside the area as parameter.
    *
    * @param x X position.
    * @param y Y position.
    */
   void fill(unsigned int x, unsigned int y)

   void degreeLine(unsigned int x, unsigned int y, int degree, unsigned int inner_radius, unsigned int outer_radius, PixelStyle style)

   /**
    * Join two LCDBitmaps.
    *
    * @param bmp bitmap to join to this bitmap.
    * @param x X position.
    * @param y Y position.
    */
   void join(const LCDBitmap& bmp, unsigned int x, unsigned int y)


Any questions, let me know.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 23:49 
Offline

Joined: Sat Feb 12, 2005 17:16
Posts: 7
Hi Henri, Hi Syridian,

i want to continue coding on my digitv-plugin and encountered a problem leading to a question concerning bitmaps.

i have 25 channel logos and several status logos, some of which are animated, and i'd like to play an animation of 3 bitmaps, for instant, dvd1bmp,dvd2.bmp, dvd3.bmp if the status would be play. Or the if the status would be live and the channel would be bbc, i want the bbc.bmp graphic being displayed. do i have to load all bitmaps at the very beginning or in the loop during the assessment ?

i would appreciate an example, if you don't mind to


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 1:11 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
You can do it either way. Load all bitmaps during initialization or then load new bitmap everytime it is shown. I would probably load all bitmaps first and then show them from memory.

This example you would like to see, you would like an example of the whole process of how to load bitmaps and then how to show them as animation ? Or something else more specific ?
Let me know and I'll make you some example.

This digi-tv plugin sounds interesting. For which software / hardware is it meant for ?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 12:04 
Offline

Joined: Sat Feb 12, 2005 17:16
Posts: 7
Morning Henri,

The plugin iss for the DigiTV Software from http://www.nebula-electronics.com/information/info.asp?Code=0001

The Software has a Shared Memory interface build in (http://www.nebula-electronics.com/support/shared_mem.asp) and so i can write informations on my VDR-LCD.

At the moment we have the Channel_No, State, Channel_Name and the Programm_Name on the LCD.

So to the Bitmaps ;)

I think we should load the Bitmaps everytime it is shown.
So we can make the plugin Compatibly to all Peopel who use iss.
We can than load the Programm_Logo on the basis of the Channel_No(LCN(Logical Channel No)).
At my location iss it :

Germany:
Programm = Channel_No(LCN)
arte-tv.com = 600
phoenix.de = 601
extra.tvtoday.de = 602
ard.de = 603
zdf.de = 604
c3sat.de = 605
kika.de = 606
doku.tvtoday.de = 606
rtl.de = 607
rtl2.de = 608
superrtl.de = 609
vox.de = 610
hr-online.de = 611
mdr.de = 612
ndr.de(NDS) = 613
ndr.de(HH) = 614
ndr.de(SH) = 615
ndr.de(MVP) = 616
wdr.de = 617
sat1.de = 618
n24.de = 619
prosieben.de = 620
kabel1.de = 621
eurosport.de = 622
terranova.de = 623
tele5.de = 624

so we can make the Logos avail :

LCN = 600 show 600.bmp
LCN = 601 show 601.bmp
and so on ....

or at other location (Melbourne):

LCN = 002 show 002.bmp
LCN = 007 show 007.bmp
and so on .....

Thats part two.

Part on iss display at the same position(variabel) the State of the Software. Paused, Play Stop .... and that as animation.

i have made a rar archiv that you can see what we have at the moment, the link send i to you per pm.

mfg Jörg


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2005 11:11 
Offline

Joined: Sat Feb 12, 2005 17:16
Posts: 7
Update now Status and Logo Bitmaps working.

Henri wrote:
This example you would like to see, you would like an example of the whole process of how to load bitmaps and then how to show them as animation ?


Yes please.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group