Bitmap not being displayed correctly

Started by Andrew February 11, 2012
Hi,

I am working in a system using an AT32UC3B512, and a colour touchscreen
display (which is driven using an SSD1963 controller).

I can display bit maps on the screen provided their width is dead on 96
pixels. If I make the width any different then they don't display
properly.

My function for writing the bitmap is:

void PutImage1BPP(uint16_t left, uint16_t top, const GLYPH_HEADER
*bm_header, unsigned char const *bm_data)
{

uint8_t temp;
uint16_t sizeX, sizeY;
uint16_t x, y;
uint8_t mask=0;

sizeX = bm_header->width;
sizeY = bm_header->height;
bm_data += bm_header->offset;
for (y=0; y {
SetArea(left, MAX_X, top+y, MAX_Y);
for(x=0;x {
if (mask == 0)
{
temp = *bm_data;
bm_data++;
mask = 0x80;
}

if (mask & temp)
{
SetPixel(left+x,top+y,0);
}

else
{
SetPixel(left+x,top+y,0xFFFFFF);//Make sure background
is white
}

mask >>= 1;
}

}
}

The GLPH_HEADER is defined as:

typedef struct
{
uint16_t height;
uint16_t width;
uint16_t offset;
} GLYPH_HEADER;

const GLYPH_HEADER bitmap_header[5] = {
79,96,0,
100,96,948,
100,96,2198,
100,96,3448,
79,96,5646

};

and the bitmap_data is an array of unsigned chars.

Could someone please point out why the bitmaps are not displayed
correctly if the width is not 96 pixels.

Thanks in advance

Andrew

Hi,
1- i see that you display a binary image on a color screen.
2- can you tel me what resolution the screen is ?
3- can you describe what wrong when your image have a deferent size, 
    try to display a image of a empty rectangle and describe me the result   
good luck  

________________________________
From: Andrew
To: a...
Sent: Saturday, February 11, 2012 5:21 PM
Subject: [AVR club] Bitmap not being displayed correctly


 
Hi,

I am working in a system using an AT32UC3B512, and a colour touchscreen
display (which is driven using an SSD1963 controller).

I can display bit maps on the screen provided their width is dead on 96
pixels. If I make the width any different then they don't display
properly.

My function for writing the bitmap is:

void PutImage1BPP(uint16_t left, uint16_t top, const GLYPH_HEADER
*bm_header, unsigned char const *bm_data)
{

uint8_t temp;
uint16_t sizeX, sizeY;
uint16_t x, y;
uint8_t mask=0;

sizeX = bm_header->width;
sizeY = bm_header->height;
bm_data += bm_header->offset;

for (y=0; y {
SetArea(left, MAX_X, top+y, MAX_Y);
for(x=0;x {
if (mask == 0)
{
temp = *bm_data;
bm_data++;
mask = 0x80;
}

if (mask & temp)
{
SetPixel(left+x,top+y,0);
}

else
{
SetPixel(left+x,top+y,0xFFFFFF);//Make sure background
is white
}

mask >>= 1;
}

}
}

The GLPH_HEADER is defined as:

typedef struct
{
uint16_t height;
uint16_t width;
uint16_t offset;
} GLYPH_HEADER;

const GLYPH_HEADER bitmap_header[5] = {
79,96,0,
100,96,948,
100,96,2198,
100,96,3448,
79,96,5646

};

and the bitmap_data is an array of unsigned chars.

Could someone please point out why the bitmaps are not displayed
correctly if the width is not 96 pixels.

Thanks in advance

Andrew




Hi Imad,

Thank you for your reply.

The screen is 480x272.

I have drawn an empty square in a 100x100 bitmap.

If I specify the size in my code as 100x96 it is displayed fine with a
bit cut off, however if a specify a width less than 96 I get this

And if the width is specified wider the diagonal does the other way.

Do you have any ideas as to what is going wrong please?

Thanks

Andrew
--- In a..., Imad Ir wrote:
>
> Hi,
> 1- i see that you display a binary image on a color screen.
> 2- can you tel me whatresolution the screen is ?
> 3- can you describe what wrong when your image have adeferent
size,br /> > try to display a image of a empty rectangle and
describe me the resultbr /> > good luck br /> >
> ________________________________
> From: Andrew ajellisuk@...
> To: a...
> Sent: Saturday, February 11, 2012 5:21 PM
> Subject: [AVR club] Bitmap not being displayed correctly
> br /> > Hi,
>
> I am working in a system using an AT32UC3B512, and a colour
touchscreen
> display (which is driven using an SSD1963 controller).
>
> I can display bit maps on the screen provided their width is dead on
96
> pixels. If I make the width any different then they don't display
> properly.
>
> My function for writing the bitmap is:
>
> void PutImage1BPP(uint16_t left, uint16_t top, const GLYPH_HEADER
> *bm_header, unsigned char const *bm_data)
> {
>
> uint8_t temp;
> uint16_t sizeX, sizeY;
> uint16_t x, y;
> uint8_t mask=0;
>
> sizeX = bm_header->width;
> sizeY = bm_header->height;
> bm_data += bm_header->offset;
>
> for (y=0; y > {
> SetArea(left, MAX_X, top+y, MAX_Y);
> for(x=0;x > {
> if (mask == 0)
> {
> temp = *bm_data;
> bm_data++;
> mask = 0x80;
> }
>
> if (mask & temp)
> {
> SetPixel(left+x,top+y,0);
> }
>
> else
> {
> SetPixel(left+x,top+y,0xFFFFFF);//Make sure background
> is white
> }
>
> mask >>= 1;
> }
>
> }
> }
>
> The GLPH_HEADER is defined as:
>
> typedef struct
> {
> uint16_t height;
> uint16_t width;
> uint16_t offset;
> } GLYPH_HEADER;
>
> const GLYPH_HEADER bitmap_header[5] = {
> 79,96,0,
> 100,96,948,
> 100,96,2198,
> 100,96,3448,
> 79,96,5646
>
> };
>
> and the bitmap_data is an array of unsigned chars.
>
> Could someone please point out why the bitmaps are not displayed
> correctly if the width is not 96 pixels.
>
> Thanks in advance
>
> Andrew
>
>



Hi again,

I tried to past a bitmap of an empty square in my last message, but it didn't post. If I draw an empty square, the 2 vertical lines appear as diagonal lines through the middle of the image. If the width is specified less than 96 the lines go diagonally to the right starting from the top left to bottom right conerners. And if the width is greater than 96, I see the opposite.

Thanks

Andrew

--- In a..., "Andrew" wrote:
>
> Hi Imad,
>
> Thank you for your reply.
>
> The screen is 480x272.
>
> I have drawn an empty square in a 100x100 bitmap.
>
> If I specify the size in my code as 100x96 it is displayed fine with a
> bit cut off, however if a specify a width less than 96 I get this
>
>
>
> And if the width is specified wider the diagonal does the other way.
>
> Do you have any ideas as to what is going wrong please?
>
> Thanks
>
> Andrew
>
>
> --- In a..., Imad Ir wrote:
> >
> > Hi,
> > 1- i see that you display a binary image on a color screen.
> > 2- can you tel me whatresolution the screen is ?
> > 3- can you describe what wrong when your image have adeferent
> size,br /> > > try to display a image of a empty rectangle and
> describe me the resultbr /> > > good luck br /> > >
> > ________________________________
> > From: Andrew ajellisuk@
> > To: a...
> > Sent: Saturday, February 11, 2012 5:21 PM
> > Subject: [AVR club] Bitmap not being displayed correctly
> >
> >
> > br /> > > Hi,
> >
> > I am working in a system using an AT32UC3B512, and a colour
> touchscreen
> > display (which is driven using an SSD1963 controller).
> >
> > I can display bit maps on the screen provided their width is dead on
> 96
> > pixels. If I make the width any different then they don't display
> > properly.
> >
> > My function for writing the bitmap is:
> >
> > void PutImage1BPP(uint16_t left, uint16_t top, const GLYPH_HEADER
> > *bm_header, unsigned char const *bm_data)
> > {
> >
> > uint8_t temp;
> > uint16_t sizeX, sizeY;
> > uint16_t x, y;
> > uint8_t mask=0;
> >
> > sizeX = bm_header->width;
> > sizeY = bm_header->height;
> > bm_data += bm_header->offset;
> >
> > for (y=0; y > > {
> > SetArea(left, MAX_X, top+y, MAX_Y);
> > for(x=0;x > > {
> > if (mask == 0)
> > {
> > temp = *bm_data;
> > bm_data++;
> > mask = 0x80;
> > }
> >
> > if (mask & temp)
> > {
> > SetPixel(left+x,top+y,0);
> > }
> >
> > else
> > {
> > SetPixel(left+x,top+y,0xFFFFFF);//Make sure background
> > is white
> > }
> >
> > mask >>= 1;
> > }
> >
> > }
> > }
> >
> > The GLPH_HEADER is defined as:
> >
> > typedef struct
> > {
> > uint16_t height;
> > uint16_t width;
> > uint16_t offset;
> > } GLYPH_HEADER;
> >
> > const GLYPH_HEADER bitmap_header[5] = {
> > 79,96,0,
> > 100,96,948,
> > 100,96,2198,
> > 100,96,3448,
> > 79,96,5646
> >
> > };
> >
> > and the bitmap_data is an array of unsigned chars.
> >
> > Could someone please point out why the bitmaps are not displayed
> > correctly if the width is not 96 pixels.
> >
> > Thanks in advance
> >
> > Andrew
> >
> >
> >
> >
> >
> >
>
>
>
>
>

hi,
your test indicate that the image memory line length is not correct, you must review the memory configuration and accepted line length for your display driver
________________________________
From: Andrew
To: a...
Sent: Sunday, February 12, 2012 6:32 PM
Subject: Re: [AVR club] Bitmap not being displayed correctly


 
Hi again,

I tried to past a bitmap of an empty square in my last message, but it didn't post. If I draw an empty square, the 2 vertical lines appear as diagonal lines through the middle of the image. If the width is specified less than 96 the lines go diagonally to the right starting from the top left to bottom right conerners. And if the width is greater than 96, I see the opposite.

Thanks

Andrew

--- In a..., "Andrew" wrote:
>
> Hi Imad,
>
> Thank you for your reply.
>
> The screen is 480x272.
>
> I have drawn an empty square in a 100x100 bitmap.
>
> If I specify the size in my code as 100x96 it is displayed fine with a
> bit cut off, however if a specify a width less than 96 I get this
>
>
>
> And if the width is specified wider the diagonal does the other way.
>
> Do you have any ideas as to what is going wrong please?
>
> Thanks
>
> Andrew
>
>
> --- In a..., Imad Ir wrote:
> >
> > Hi,
> > 1- i see that you display a binary image on a color screen.
> > 2- can you tel me what resolution the screen is ?
> > 3- can you describe what wrong when your image have a deferent
> size,Â
> > Â Â Â try to display a image of a empty rectangle and
> describe me the result  Â
> > good luck Â
> >
> > ________________________________
> > From: Andrew ajellisuk@
> > To: a...
> > Sent: Saturday, February 11, 2012 5:21 PM
> > Subject: [AVR club] Bitmap not being displayed correctly
> >
> >
> > Â
> > Hi,
> >
> > I am working in a system using an AT32UC3B512, and a colour
> touchscreen
> > display (which is driven using an SSD1963 controller).
> >
> > I can display bit maps on the screen provided their width is dead on
> 96
> > pixels. If I make the width any different then they don't display
> > properly.
> >
> > My function for writing the bitmap is:
> >
> > void PutImage1BPP(uint16_t left, uint16_t top, const GLYPH_HEADER
> > *bm_header, unsigned char const *bm_data)
> > {
> >
> > uint8_t temp;
> > uint16_t sizeX, sizeY;
> > uint16_t x, y;
> > uint8_t mask=0;
> >
> > sizeX = bm_header->width;
> > sizeY = bm_header->height;
> > bm_data += bm_header->offset;
> >
> > for (y=0; y > > {
> > SetArea(left, MAX_X, top+y, MAX_Y);
> > for(x=0;x > > {
> > if (mask == 0)
> > {
> > temp = *bm_data;
> > bm_data++;
> > mask = 0x80;
> > }
> >
> > if (mask & temp)
> > {
> > SetPixel(left+x,top+y,0);
> > }
> >
> > else
> > {
> > SetPixel(left+x,top+y,0xFFFFFF);//Make sure background
> > is white
> > }
> >
> > mask >>= 1;
> > }
> >
> > }
> > }
> >
> > The GLPH_HEADER is defined as:
> >
> > typedef struct
> > {
> > uint16_t height;
> > uint16_t width;
> > uint16_t offset;
> > } GLYPH_HEADER;
> >
> > const GLYPH_HEADER bitmap_header[5] = {
> > 79,96,0,
> > 100,96,948,
> > 100,96,2198,
> > 100,96,3448,
> > 79,96,5646
> >
> > };
> >
> > and the bitmap_data is an array of unsigned chars.
> >
> > Could someone please point out why the bitmaps are not displayed
> > correctly if the width is not 96 pixels.
> >
> > Thanks in advance
> >
> > Andrew
> >
> >
> >
> >
> >
> >
>
>
>
>
>




Hi,
If you look at the second parameter in each line of the GLYPH_HEADER
bitmap_header, you have set the width of the bitmap tp 96 pixels.
If you want to change the width of the bitmap, you must also change the
bitmap_header to the same value.

//Peo
<-----Ursprungligt Meddelande----->

From: Andrew [a...@yahoo.co.uk]
Sent: 11/2/2012 4:21:04 PM
To: a...
Subject: [AVR club] Bitmap not being displayed correctly



const GLYPH_HEADER bitmap_header[5] = {
79,96,0,
100,96,948,
100,96,2198,
100,96,3448,
79,96,5646

};

and the bitmap_data is an array of unsigned chars.

Could someone please point out why the bitmaps are not displayed
correctly if the width is not 96 pixels.

Thanks in advance

Andrew

_______________________________________________________________
F50-90 % rabatt i din stad - Gratis! Se dagens Deal h
Pupplevelser, middagar, sportevenemang, teknik, resor och mer.




Thank you for you replies,

I had forgotten to reply to this post when I was busier.

It seemed that the problem was more to do with the hex converter http://en.radzio.dxp.pl/bitmap_converter/ than my code. It just didn't work if the width of the bitmap was more than 96 pixels.

For the time being I resorted to using multiple bitmaps to tile my image.

Andrew

--- In a..., Per Hensen wrote:
>
>
> Hi,
> If you look at the second parameter in each line of the GLYPH_HEADER
> bitmap_header, you have set the width of the bitmap tp 96 pixels.
> If you want to change the width of the bitmap, you must also change the
> bitmap_header to the same value.
>
> //Peo
>
>
> <-----Ursprungligt Meddelande----->
>
> From: Andrew [ajellisuk@...]
> Sent: 11/2/2012 4:21:04 PM
> To: a...
> Subject: [AVR club] Bitmap not being displayed correctly
>
>
>
> const GLYPH_HEADER bitmap_header[5] = {
> 79,96,0,
> 100,96,948,
> 100,96,2198,
> 100,96,3448,
> 79,96,5646
>
> };
>
> and the bitmap_data is an array of unsigned chars.
>
> Could someone please point out why the bitmaps are not displayed
> correctly if the width is not 96 pixels.
>
> Thanks in advance
>
> Andrew
>
>
>
>
>
>
>

_______________________________________________________________
F50-90 % rabatt i din stad - Gratis! Se dagens Deal h
Pupplevelser, middagar, sportevenemang, teknik, resor och mer.
>

>
>
>


Hi again,

I have finally resolved the mystery. The dimensions of my images must be divisible by 8. If they are not, the bitmap will not be displayed correctly.

Andrew

--- In a..., "Andrew" wrote:
>
> Thank you for you replies,
>
> I had forgotten to reply to this post when I was busier.
>
> It seemed that the problem was more to do with the hex converter http://en.radzio.dxp.pl/bitmap_converter/ than my code. It just didn't work if the width of the bitmap was more than 96 pixels.
>
> For the time being I resorted to using multiple bitmaps to tile my image.
>
> Andrew
>
> --- In a..., Per Hensen wrote:
> >
> >
> > Hi,
> > If you look at the second parameter in each line of the GLYPH_HEADER
> > bitmap_header, you have set the width of the bitmap tp 96 pixels.
> > If you want to change the width of the bitmap, you must also change the
> > bitmap_header to the same value.
> >
> > //Peo
> >
> >
> > <-----Ursprungligt Meddelande----->
> >
> > From: Andrew [ajellisuk@]
> > Sent: 11/2/2012 4:21:04 PM
> > To: a...
> > Subject: [AVR club] Bitmap not being displayed correctly
> >
> >
> >
> > const GLYPH_HEADER bitmap_header[5] = {
> > 79,96,0,
> > 100,96,948,
> > 100,96,2198,
> > 100,96,3448,
> > 79,96,5646
> >
> > };
> >
> > and the bitmap_data is an array of unsigned chars.
> >
> > Could someone please point out why the bitmaps are not displayed
> > correctly if the width is not 96 pixels.
> >
> > Thanks in advance
> >
> > Andrew
> >
> >
> >
> >
> >
> >
> >

_______________________________________________________________
F50-90 % rabatt i din stad - Gratis! Se dagens Deal h
Pupplevelser, middagar, sportevenemang, teknik, resor och mer.
> >

> >
> >
>