BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Filling a rectangle with tiles.  (Read 8748 times)

rascalito

  • Newbie
  • *
  • Posts: 16
    • View Profile
Filling a rectangle with tiles.
« on: June 04, 2021, 03:21:24 AM »

Hello!

I have been playing with bitmaps for a while, and I found something odd.
At first, after reading about bitmap layout, bitmap size, I discoverd that wrapx and wrapy
allow to tile a rectangle. Here is an example of tiling a rectangle with a smaller bitmap.
[apparently no way to attach pictures inline. I hope they will be attached below]

In the image IMG_4411.jpeg, the tile can be clearly shown. The tile size is 8 x 8.
The good thing about this is that with a very limited number of commands, you can
tile a large rectangle, even the full screen.

Now if I want to tile with a slightly different bitmap, it doesn't work at all. See the example
with a 8 x 9 bitmap. What I did is simply repeating the last line of the uint8[] array of that bitmap.

Here is what I could capture on the scope. It's the whole SPI communication between
the processor (STM32) and the LCD. Let's examine the 2 captures. Just to make sure
of what changes, I first took the 2 captures, separated everything by 4 bytes except the
3 first bytes, and then ran the diff utility on Ubuntu. I could make sure that only 3 lines
are different.
1. The working bitmap. Not much to say. There are 2 bitmaps, one large bitmap at (100, 0). tiled
with the small 8x8 bitmap that I also wrote at (0, 100).
Code: [Select]
B0 25 78 // Command buffer
00 FF FF FF // CMD_DLSTART
90 60 30 02 // Set clear color to bluish
07 00 00 26 // Clear with the 3 flags (0x07)
00 10 00 01 // Bitmap source (defined as 0x01000000 + address which is 0x1000)
08 20 00 07 // Bitmap layout (defined as 0x07000000. height = 8, linestride = 2 * 8 (0x10), shifted by 9 = 0x2000)
08 10 00 08 // Bitmap size (defined as 0x08000000. height = 8, width = 8, shifted by 9 = 0x1000
01 00 00 1F // DL_BEGIN bitmaps
00 40 06 80 // Vertex
00 10 00 01 // Same bitmap source as above
08 20 00 07 // Same bitmap layout
64 C8 0C 08 // Bitmap size. This time a large bitmap (100 x 100). 100 = 0x64. Shifted left by 9 is 0xC800 wrapx and wrapy flags.
01 00 00 1F // DL_BEGIN bitmaps
00 00 80 8C // Vertex
00 00 00 00 // DL_DISPLAY
01 FF FF FF // CMD_SWAP

2. The incorrect bitmap. Only lines 6, 7, 11 (marked with a * after //) change. The small tile
bitmap height is now 9 instead of 8. The width doesn't change.
Code: [Select]
B0 25 78 // Command buffer
00 FF FF FF // CMD_DLSTART
90 60 30 02 // Set clear color to bluish
07 00 00 26 // Clear with the 3 flags (0x07)
00 10 00 01 // Bitmap source (defined as 0x01000000 + address which is 0x1000)
09 20 00 07 //* Bitmap layout (defined as 0x07000000. height = 9, linestride = 2 * 8 (0x10), shifted by 9 = 0x2000)
09 10 00 08 //* Bitmap size (defined as 0x08000000. height = 9, width = 8, shifted by 9 = 0x1000
01 00 00 1F // DL_BEGIN bitmaps
00 40 06 80 // Vertex
00 10 00 01 // Same bitmap source as above
09 20 00 07 //* Same bitmap layout as above
64 C8 0C 08 // Bitmap size. This time a large bitmap (100 x 100). 100 = 0x64. Shifted left by 9 is 0xC800 wrapx and wrapy flags.
01 00 00 1F // DL_BEGIN bitmaps
00 00 80 8C // Vertex
00 00 00 00 // DL_DISPLAY
01 FF FF FF // CMD_SWAP

I also tried to tile with a 16x16 small bitmap and it works, even if the large bitmap is not a multiple of 16.
But I couldn't tile with a 48 x 48 bitmap.

So I would like to have some feedback. If it's not possible with other formats than
8x8, 16x16 and possibly a few others, I can live with it, but I just need to know.

Best regards,

R
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: Filling a rectangle with tiles.
« Reply #1 on: June 07, 2021, 04:08:47 PM »

Hi,

Please note that there is a condition in the use of the wrap x and wrap y if you set them to repeat. The result is only defined if the respective dimension is a power of two,

Therefore your 9 would not give a defined result and also your 48 would be the same. As you said, it is a useful technique for a background etc. but you would need to use an image with power of two in both dimensions,

Here is an explanation from the BT81x Programmers guide,

BITMAP_SIZE:   This command controls the drawing of bitmaps: the on-screen size of the bitmap, the behaviour for
wrapping, and the filtering function. Please note that if wrapx or wrapy is REPEAT then the
corresponding memory layout dimension (BITMAP_LAYOUT line stride or height) must be power of
two, otherwise the result is undefined.

Best Regards, BRT Community
Logged

rascalito

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Filling a rectangle with tiles.
« Reply #2 on: June 08, 2021, 01:17:30 AM »

Hello!

Thanks for your reply. Ok, that explains it all. I should have thought about it or at least read the docs more accurately.

Thanks again!
Logged