The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

1.8" LCD & Large BMP question.

by nam3ci on Wed Dec 05, 2012 3:53 am

Hello!

I've been searching the forum but have not found it. :(

I'm doing a project and need to show a portion of a large BMP in the 1.8 "LCD.

The idea is that from an image of a size (for example) of 1024 x 1024 pixels display only a region of 160x128 pixels giving x and y coordinates for any point in the image.

Anyone know how to create a function like found in the library that draws a BMP to do this?

Thank you!
User avatar
nam3ci
 
Posts: 3
Joined: Wed Dec 05, 2012 3:44 am

Re: 1.8" LCD & Large BMP question.

by pburgess on Wed Dec 05, 2012 6:46 pm

Have a look at the spitftbitmap sketch included with the current ST7735 LCD library. I've never specifically tested it against an image that large, but in theory it should handle the cropping OK.
User avatar
pburgess
 
Posts: 2422
Joined: Sun Oct 26, 2008 1:29 am

Re: 1.8" LCD & Large BMP question.

by nam3ci on Thu Dec 06, 2012 4:38 am

Ok. I'll try It.

I was using the old library . :wink:

Thank you!

**** EDIT ***

Image cropped correct at (0,0) position to screen size, now only I need to change origin position to another , for example (10,20) and show the image. It's seems easy changing "pos" in:

Code: Select all | TOGGLE FULL SIZE
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // Need seek?
            bmpFile.seek(pos);
            buffidx = sizeof(sdbuffer); // Force buffer reload
          }
User avatar
nam3ci
 
Posts: 3
Joined: Wed Dec 05, 2012 3:44 am

Re: 1.8" LCD & Large BMP question.

by nam3ci on Thu Dec 06, 2012 10:51 am

Solved!!!! :mrgreen:

In bmpDraw function I've changed:

Code: Select all | TOGGLE FULL SIZE
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;


by

Code: Select all | TOGGLE FULL SIZE
pos = ( bmpImageoffset + (orig_x * 3)) + (bmpHeight - 1 - ( row + orig_y)) * rowSize ;


Where orig_x and orig_y are the new origin for image.
User avatar
nam3ci
 
Posts: 3
Joined: Wed Dec 05, 2012 3:44 am