Drawing part of a bitmap only

Hello everyone.

After some searching i has unable to find any code to draw only a part of a bitmap using the UTFT library.

In my desperation i have make a crude function that will do this for me.

The function will redraw any portion of a bitmap rather that redrawing the entire bitmap.
I am sure this will be usable in many applications.

the code and a demo is shared below and is free to use and modify. code is also available as a zip.
please share all improvements on this thread so that it may be developed to work for everyone.

Please note that the demo was developed on a CTE70 display in 800 * 480 resolution in portrait orientation.
I also used an arduino due on ide 1.5.5.
you will need to use the UTFT library from henning karlsen. Electronics - Henning Karlsen

code is here, uploads to the forum is FULL.

// redraw bitmap function by ewan van teijlingen
// january 12 2014


#include <UTFT.h>                                  

UTFT          myGLCD(CTE70,25,26,27,28);                 

void setup()
{
myGLCD.InitLCD();                                                                            
myGLCD.clrScr();  
myGLCD.clrScr();
}

// Dimensions    : 200x120 pixels
// Size          : 48,000 Bytes

unsigned short Background[0x5DC0] = 
{
// insert image array of 200 * 120 here or download the code from the hyperlink above
};



void DrawBackground (int OriginalHPos, int OriginalVPos, int ImageSizeH, int ImageSizeV, unsigned short data[], int Scale, int ScreenHSize, int ScreenVSize, int HStart,int VStart,int HStop,int VStop)
{    
  
unsigned short TempBackgound[0x1E0];

    VStart = map(VStart, 0, ScreenVSize, 0, (ScreenVSize / Scale));   
    VStop =  map(VStop,  0, ScreenVSize, 0, (ScreenVSize / Scale)); 
    HStart = map(HStart, 0, ScreenHSize, 0, (ScreenHSize / Scale));   
    HStop =  map(HStop,  0, ScreenHSize, 0, (ScreenHSize / Scale)); 
    
    for (int I = VStart ; I < VStop ; I++) 
    {
      int Count = 0; 
      
      for (int K = ((I * (ImageSizeH)) + HStart) ; K < ((I * (ImageSizeH)) + ((HStop - HStart) + ImageSizeH)) ; K++) 
      {
        TempBackgound[Count] =  data[K];
        Count++; 
      }  
    myGLCD.drawBitmap( OriginalHPos + (HStart * Scale), OriginalVPos + (I * Scale), (HStop - HStart) ,1 , TempBackgound,  Scale);
    }       
}






void loop()                                                                                                
{
  


DrawBackground(0,0,200,120,Background,4,800,480,0,0,800,480);  
delay(1000);


DrawBackground(200,120,200,120,Background,2,800,480,0,0,400,240); 
delay(1000);

DrawBackground(300,180,200,120,Background,1,800,480,0,0,200,120); 
delay(1000);

myGLCD.setColor(VGA_GREEN);
myGLCD.fillRect(350,200,450,240); 
delay(1000);

DrawBackground(300,180,200,120,Background,1,800,480,20,20,180,100); 
delay(1000);

DrawBackground(200,120,200,120,Background,2,800,480,50,60,350,180); 
delay(1000);

DrawBackground(0,0,200,120,Background,4,800,480,200,120,600,360); 
delay(1000);




myGLCD.setColor(VGA_RED);
myGLCD.fillRect(0,240,800,480); 
delay(1000);

DrawBackground(0,0,200,120,Background,4,800,480,0,240,800,480);  
delay(1000);

DrawBackground(200,120,200,120,Background,2,800,480,0,0,400,240);  
delay(1000);

myGLCD.setColor(VGA_RED);
myGLCD.fillRect(300,240,500,360); 
delay(1000);

DrawBackground(200,120,200,120,Background,2,800,480,0,120,400,240);  
delay(1000);

                                                                      
}

Hoi Ewan.

You forgot to attach your code or a link to it.

use the HYPERLINK BUTTON to add links (second row, 3rd from the left)