biplab said:
What have you tried so far?
--
Richard Heathfield <
http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <
http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
I have read the file using fopen...and then read the value...bt
nothing is read...I have a code in C which access the vedio memory to
print an image....can you please help me out from that code how can i
read the pixel vales and have the same image as output as the input...
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <mem.h>
#include <string.h>
#include <conio.h>
#include <fcntl.h>
#include <io.h>
#include <math.h>
unsigned char r[360],mini,mode;
unsigned char rgb[256][3];
char *fullname;
char *fname;
unsigned int screen_width=320;
unsigned int first_row=0,first_column=0,last_row=0,last_column=0;
int handle,i,j,rem,color_bits;
long int
file_size,data_offset,size_info_header,width,height,compression,
image_size,xpelspermeter,ypelspermeter,colorsused,colorsimpt;
float theta;
void drawdot(int y, int x, int pal_index){
_AX=pal_index;
_CX=x;
_DX=y;
_AH=0x0c;
_BH=0x00;
geninterrupt(0x10);
}
void main(){
gets(fname);
strcpy(fullname,fname);
strcat(fullname,".bmp");
handle=_open(fullname,O_RDONLY);
if (handle==-1) exit(EXIT_FAILURE);
_read(handle,r,2);
if (r[0] !='B' | r[1] !='M') exit(EXIT_FAILURE);
_read(handle,r,
4);file_size=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,2);
_read(handle,r,2);
_read(handle,r,4);
data_offset=r[0]+256*r[1]+65536*r[2]+0x1000000*r[3];
_read(handle,r,4);
size_info_header=r[0]+256*r[1]+65536*r[2]+0x1000000*r[3];
if (size_info_header !=40) exit(EXIT_FAILURE);
_read(handle,r,4);
width=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
if (width > screen_width) exit(0);
_read(handle,r,4);
height=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,2);
if (r[0] != 1) exit(EXIT_FAILURE);
_read(handle,r,2);
color_bits=r[0];
_read(handle,r,4);
compression=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,4);
image_size=r[0]+256*r[1]+256*256*r[2]+256*256*256*r[3];
_read(handle,r,4);
xpelspermeter=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,4);
ypelspermeter=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,4);
colorsused=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_read(handle,r,4);
colorsimpt=r[0]+0x100*r[1]+0x10000*r[2]+0x1000000*r[3];
_AX=0x1201;_BL=0x33;geninterrupt(0x10);//don't add RGB
_AX=0x0013;geninterrupt(0x10);//set mode 13 i.e. 320x200x256
for (i=0;i<256;i++) {
_read(handle,r,4);
rgb
[0]=r[2];rgb[1]=r[1];rgb[2]=r[0];
}
_ES=FP_SEG(rgb);_DX=FP_OFF(rgb);
_BX=0;_CX=0x100; _AX=0x1012;
geninterrupt(0x10);//set DAC from rgb
first_column=(screen_width-width)/2;
last_row=first_row+height-1;
last_column=first_column+width-1;
rem=4 - (width % 4);
for (i=0;i<=height-1;i++) {
_read(handle,r,width);
for (j=0;j<=width-1;j++) drawdot(first_column+j,last_row-i,r[j]);
if (rem==1) _read(handle,r,1);
else if (rem==2) _read(handle,r,2);
else if (rem==3) _read(handle,r,3);//getch();
}
_close(handle);
getch();
_AX=0x1201;_BL=0x33;geninterrupt(0x10);//don't add RGB
_AX=0x0003;geninterrupt(0x10);//set mode 3 i.e. 16-color text
}
1st of all i will be highly obliged if you let me know what the code
is doing and how??/As i have found the code in the internet and am a
newbie in C...
thanks in advance...
biplab