A
a9Az
#include <stdio.h>
#include <graphics.h>
int draw(int x0, int y0,char* fname)
{
unsigned char color[16]={0,4,2,6,1,5,7,8,12,10,14,9,13,11,15};
struct bmpinfo
{
char h1,h2;
unsigned long
size,reserved,offset,b,width,height;
unsigned int
plans,bpp;
};
bmpinfo info;
FILE *f;
int x,y;
unsigned char b;
unsigned char bh;
unsigned char bl;
int nb;
int np;
int i,j;
if((f=fopen(fname,"rb"))==NULL)
// system("PAUSE");
return -1;
fread(&info,sizeof(info),1,f);
if (info.bpp !=4)
return -2;
x=x0;
y=y0+info.height;
nb=(info.width/8)*4;
if((info.width/8) !=0) nb +=4;
fseek(f, info.offset, SEEK_SET);
//ВЫВОД ИЛЛЮСТРАЦИИ
for (i=0; i<info.height; i++)
{
np=0;
for (j=0; j<nb; j++)
{
b=fgetc(f);
if (np<info.width)
{
bh=b>>4;
int putpixel(x,y,color[bh]);
x++;
np++;
}
if (np<info.width)
{
bl=b & 15;
void putpixel(x,y,color[bl]);
x++;
np++;
}
}
x=x0;
y--;
}
fclose(f);
return info.height;
}
#include <graphics.h>
int draw(int x0, int y0,char* fname)
{
unsigned char color[16]={0,4,2,6,1,5,7,8,12,10,14,9,13,11,15};
struct bmpinfo
{
char h1,h2;
unsigned long
size,reserved,offset,b,width,height;
unsigned int
plans,bpp;
};
bmpinfo info;
FILE *f;
int x,y;
unsigned char b;
unsigned char bh;
unsigned char bl;
int nb;
int np;
int i,j;
if((f=fopen(fname,"rb"))==NULL)
// system("PAUSE");
return -1;
fread(&info,sizeof(info),1,f);
if (info.bpp !=4)
return -2;
x=x0;
y=y0+info.height;
nb=(info.width/8)*4;
if((info.width/8) !=0) nb +=4;
fseek(f, info.offset, SEEK_SET);
//ВЫВОД ИЛЛЮСТРАЦИИ
for (i=0; i<info.height; i++)
{
np=0;
for (j=0; j<nb; j++)
{
b=fgetc(f);
if (np<info.width)
{
bh=b>>4;
int putpixel(x,y,color[bh]);
x++;
np++;
}
if (np<info.width)
{
bl=b & 15;
void putpixel(x,y,color[bl]);
x++;
np++;
}
}
x=x0;
y--;
}
fclose(f);
return info.height;
}