#112313 - tecljg - Fri Dec 15, 2006 4:48 am
hi,
the documents say the NDS icon 32x32 pixels, 4x4 tile, i write a program under windows, but can not display the icon properly,anybody can give more detailed explaination. what's the 4x4 tile?
Below is my program:
void displat_icon()
{
// read icon from nds file
readicon(ico);
unsigned short color[16];
unsigned short *ptr = (unsigned short *)(ico+544);
// Get palette
for(i=0;i<16;i++)
{
color[i]=*ptr++;
}
BYTE *ptr2 = ico+32; // point to icon data
// x, y is draw start position
int x=100, y=100, count=0;
for(i=0;i<32;i++) // 32 pixels width
{
for(int j=0;j<32;j++) // 32 pixels height
{
BYTE b = ptr2[count/2]; // one byte consist of two pixels
BYTE b2,b3;
// one pixel is 4 bits,
b2 = (b>>4)&0xf; // first pixel color palette index
b3 = b&0xf; // second pixel color palette index
unsigned short c1=color[b2], c2=color[b3];
BYTE rr1,gg1,bb1;
BYTE rr2,gg2,bb2;
// first pixel\'s RGB
rr1=(c1&0x1f)<<3;
gg1=((c1>>5)&0x1f)<<3;
bb1=((c1>>10)&0x1f)<<3;
// second pixel\'s RGB
rr2=(c2&0x1f)<<3;
gg2=((c2>>5)&0x1f)<<3;
bb2=((c2>>10)&0x1f)<<3;
CDC *dc = GetDC();
if(b2) // 0 is transparent
dc->SetPixel(x,y,RGB(r1,g1,bb1));
x++; // drawing move to next
if(b3) // 0 is transparent
dc->SetPixel(x,y,RGB(r2,g2,bb2));
count+=1;
}
x=100;
y++; // next line
}
Thanks.
the documents say the NDS icon 32x32 pixels, 4x4 tile, i write a program under windows, but can not display the icon properly,anybody can give more detailed explaination. what's the 4x4 tile?
Below is my program:
void displat_icon()
{
// read icon from nds file
readicon(ico);
unsigned short color[16];
unsigned short *ptr = (unsigned short *)(ico+544);
// Get palette
for(i=0;i<16;i++)
{
color[i]=*ptr++;
}
BYTE *ptr2 = ico+32; // point to icon data
// x, y is draw start position
int x=100, y=100, count=0;
for(i=0;i<32;i++) // 32 pixels width
{
for(int j=0;j<32;j++) // 32 pixels height
{
BYTE b = ptr2[count/2]; // one byte consist of two pixels
BYTE b2,b3;
// one pixel is 4 bits,
b2 = (b>>4)&0xf; // first pixel color palette index
b3 = b&0xf; // second pixel color palette index
unsigned short c1=color[b2], c2=color[b3];
BYTE rr1,gg1,bb1;
BYTE rr2,gg2,bb2;
// first pixel\'s RGB
rr1=(c1&0x1f)<<3;
gg1=((c1>>5)&0x1f)<<3;
bb1=((c1>>10)&0x1f)<<3;
// second pixel\'s RGB
rr2=(c2&0x1f)<<3;
gg2=((c2>>5)&0x1f)<<3;
bb2=((c2>>10)&0x1f)<<3;
CDC *dc = GetDC();
if(b2) // 0 is transparent
dc->SetPixel(x,y,RGB(r1,g1,bb1));
x++; // drawing move to next
if(b3) // 0 is transparent
dc->SetPixel(x,y,RGB(r2,g2,bb2));
count+=1;
}
x=100;
y++; // next line
}
Thanks.