hola , me gustaría que me pudieran ayudar a cargar una imagen en lenguaje C, yo uso el compilador de TC20 por que es el que utiliza la universidad.
yo tengo el siguiente código
el cual aparentemente si lee la imagen pero a la hora de mostrarla en pantalla no lo hace como me gustaría obteniendo el siguiente resultado

nada en comparacion con la que quiero insertar

les agradecería mucho si me pudieran ayudar
yo tengo el siguiente código
Código (c) [Seleccionar]
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <conio.h>
#include <graphics.h>
int loadbitmap(char *filename,int,int);
main ()
{
loadbitmap("p.bmp",100,100);
getch();
}
int loadbitmap(char *filename,int wid,int hei)
{
FILE *ptr=NULL;
int width,height, ch,ch1,ch2;
unsigned long temp=0,i=0,j=0;
unsigned long ww;
char *linea;
int adapta, modo;
detectgraph(&adapta,&modo);
initgraph(&adapta,&modo,"");
ptr=fopen(filename,"rb");
linea = (char *) malloc (sizeof(ptr));
if(!ptr) return 0;
width=0;height=0;
fseek(ptr,18,SEEK_SET);
fread(linea, width, 1, ptr);
for(i=0x1;i<=0x10000;i*=0x100)
{
temp=fgetc(ptr);
width+=(temp*i);
}
fseek(ptr,22,SEEK_SET);
for(i=0x1;i<=0x10000;i*=0x100)
{
temp=fgetc(ptr);
height+=(temp*i);
}
ww=width;
if(ww%2)
ww++;ww/=2;
if(ww%4)
ww=(ww/4)*4+4;
fseek(ptr,119,SEEK_SET);
moveto(200,300);
for(i=0;i<height;i++)
for(j=0;j<ww;j++)
{
ch=fgetc(ptr);
ch1=ch;ch2=ch;
ch1=ch1&(0xf0);ch1=ch1>>4;
ch2=ch2&(0x0f);
if(j*2<width)
putpixel((j)*2+wid,(hei+height-1-i),getcol(ch1));
if(j*2+1<width)
putpixel((j)*2+1+wid,(hei+height-1-i),getcol(ch2));
}
fclose(ptr);
return 1;
}
int getcol(int col)
{
switch(col)
{
case 0: return 0;
case 1: return 4;
case 2: return 2;
case 3: return 6;
case 4: return 1;
case 5: return 5;
case 6: return 3;
case 7: return 7;
case 8: return 8;
case 9: return 12;
case 10:return 10;
case 11:return 14;
case 12:return 9;
case 13:return 13;
case 14:return 11;
case 15:return 15;
}
return col;
}
el cual aparentemente si lee la imagen pero a la hora de mostrarla en pantalla no lo hace como me gustaría obteniendo el siguiente resultado

nada en comparacion con la que quiero insertar

les agradecería mucho si me pudieran ayudar