On Sep 10, 6:12*pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
biplab said:
Hi all,
I want to read the pixel values of a .bmp image(which will be input to
the code) into a matrix...plz help me out as i can not understand how
to achieve this...
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=32 0;
unsigned int first_row=0,fir st_column=0,las t_row=0,last_co lumn=0;
int handle,i,j,rem, color_bits;
long int
file_size,data_ offset,size_inf o_header,width, height,compress ion,
image_size,xpel spermeter,ypels permeter,colors used,colorsimpt ;
float theta;
void drawdot(int y, int x, int pal_index){
_AX=pal_index;
_CX=x;
_DX=y;
_AH=0x0c;
_BH=0x00;
geninterrupt(0x 10);
}
void main(){
gets(fname);
strcpy(fullname ,fname);
strcat(fullname ,".bmp");
handle=_open(fu llname,O_RDONLY );
if (handle==-1) exit(EXIT_FAILU RE);
_read(handle,r, 2);
if (r[0] !='B' | r[1] !='M') exit(EXIT_FAILU RE);
_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_heade r=r[0]+256*r[1]+65536*r[2]+0x1000000*r[3];
if (size_info_head er !=40) exit(EXIT_FAILU RE);
_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_FAILU RE);
_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;geninterru pt(0x10);//don't add RGB
_AX=0x0013;geni nterrupt(0x10);//set mode 13 i.e. 320x200x256
for (i=0;i<256;i++) {
_read(handle,r, 4);
rgb[i][0]=r[2];rgb[i][1]=r[1];rgb[i][2]=r[0];
}
_ES=FP_SEG(rgb) ;_DX=FP_OFF(rgb );
_BX=0;_CX=0x100 ; _AX=0x1012;
geninterrupt(0x 10);//set DAC from rgb
first_column=(s creen_width-width)/2;
last_row=first_ row+height-1;
last_column=fir st_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_c olumn+j,last_ro w-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;geninterru pt(0x10);//don't add RGB
_AX=0x0003;geni nterrupt(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