Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Image represents the intensity level by numbers from 0 to 2 16 and so on. There
are 2 types of images based on intensity variation viz.
Monochrome Image.
Color Image.
Once any image is digitally converted the information is saved in a binary format
in an image file. An image file consist of 2 sectors such as.
A header field
The data field
The data field recedes the header field. The converted data is stored in
the data field. All the images require a huge set of memory for storing display
purpose. Memory is an expensive issue for the software developers. Hence all
the images are first compressed and then stored into the file. After compression
the image loses some of the information. An image format is said to be a good
format if it achieves higher compression ratio without losing much information.
Viewing any image requires the decompression of the file and glow the points on
the screen suitably by reading the intensity information from the file. A header
comprises of all the information required by a decoder which should enable the
decoder to decode the image or display the image. The BMP file format achieves
very minimum compression ratio in comparison with the other formats. Hence the
processing speed requires to display the BMP images is bit lesser in comparison
with the other methods. We have tried to develop a BMP utility for DOS which
would display a BMP file into the DOS. There has been no such utility available
in DOS. Hence the technology is a great achiever in terms of crossing the
limitations of text based operating system and enhances its features to display
complex objects like images into the screen.
Present System:
As we all know that DOS is a text operating system; hence it doesn’t
provide a capability of displaying the image. The image viewers that are available
in the market today are all for windows services. Some of them are product
picture viewer, MS-Paint etc. All of them are capable of displaying complicated
and rich images because windows and other major operating system support
high density pixel and 32 bit quantization. Hence it was important to develop an
image viewer which would be able to display the images in DOS.
Proposed System:
The system that we are proposing here in our project is an ultimate utility
in DOS. It reads the header of the image file first and finds out the number of
rows and the columns that it needs to read out from the date segment of the
image file. It than starts reading the data from the file byte by byte and glow the
corresponding pixel in the screen with the intensity that is been read from the
image file. Hence it also needs to have the information about the byte format and
quantization factor of the encoder. Once the information of the pixel is available it
is put in the screen by assigning it to the AX register of the CPU and by
generating video interrupt. With this all the pixels are read, the image is displayed
in the screen. Time is a major factor over here as number of pixels needs to be
read, is quite high. Hence this system works best with advanced processors with
high memory support.
Implementation:
The project provides 2 different utility services:
To view all the BMP files as a graphical files present in the current
directory.
A system which accepts the file name as the input & draw the image.
System Requirement:
Functional Requirement:
The BMP utility displays the BMP images into the screen. Hence the most
functional and basic requirement of the system is BMP file which would be
displayed. The next thing that is important over here is the processing speed and
the processing capability of the processor to be very high and the parallel.
Processing must be fast. The RAM requirement over here is also very high
because the buffer size needed to hold the image is very high. Hence even
though the system is designed predominantly for DOS users this will not be
supported by low configuration PCs. The other requirements include:
To understand the image information: The current system cannot display
3D images. Hence the user must not pass any 3D images to the display
routine.
To have accelerated graphics card in the system. Th accelerated graphics
card are electronics devices or peripherals which present tremendous
capability to the video by providing the video driver with a memory of
above 5K. Higher the memory of the card, better the speed of the display
becomes. Without the presence of the card it would it long period to
display any image.
Non-Functional Requirement:
Advantages:
It is first of its kind to show any images into DOS.
Can read image of any size lesser than 1024 by 1024 size.
Can be used to display various drives folders.
It using direct user memory hence serialization problem is removed.
Disadvantages:
View port transformation problem may cause information lose
which results in image distortion.
High memory requirement.
High processing speed is required.
Image manipulations are not possible.
Application:
Conclusion:
The project has been one of the premature efforts to display BMP images
in DOS. The system is not a perfect one as memory optimization is not been
looked after. Beside the system is too dependent on configuration of the system.
Hence the performance cannot be optimal in various PCs. It is strongly a
hardware dependent system. For more adoptivating the logic must be improved
so that the result must be same for almost all the configuration.
Bibliography:
#include<process.h>
#include <stdio.h>
#include <string.h>
#include <graphics.h>
#include <dir.h>
#include <dos.h>
#include <conio.h>
#define FILE1 1
#define FOLDER 2
#define EXE 3
#define BAT 4
#define COM 5
//**********************************************************************
********// FUNCTION PROTOTYPES
//**********************************************************************
********//
struct BMPHeader
{
unsigned short bfType;
long bfSize, bfReserved, bfOffBits, biSize, biWidth, biHeight;
unsigned short biPlanes, biBitCount;
long biCompression, biSizeImage, biXPelsPerMeter,
biYPelsPerMeter;
long biClrUsed, biClrImportant;
} Header;
FILE * gInpFile;
void ReadDirc();
void Icon(int x,int y,int of);
void Show(int,int,char *,int);
int Extension(char *in);
void Init();
void func1(char*);
void win(int sx,int sy,int ex,int ey,int ck);
void InitScreen(void);
void ReadHeader(void);
void ReadImg(void);
//File handle
//FILE * gInpFile;
//**********************************************************************
********//
void main()
{
Init();
ReadDirc();
char* argv=" ";
getch();
cleardevice();
closegraph();
printf("Enter File Name\n");
scanf("%s",argv);
func1(argv);
closegraph();
}
//**********************************************************************
********/// SWITCH INTO GRAPHICS & SETS THE BACKGROUND
//**********************************************************************
********//
void Init()
{
int d=DETECT,m;
// for stand alone
/*
registerfarbgidriver(EGAVGA_driver_far);
registerfarbgifont(sansserif_font_far);
registerfarbgifont(small_font_far);
registerfarbgifont(gothic_font_far);
registerfarbgifont(triplex_font_far);
*/
get_direc(text);
printf("\ncurrent directory is : %s",text);
printf("\nPress any Key to see files (*.*)...\n");
getch();
initgraph(&d,&m,"d:\\tc\\bgi");
startx=50;
starty=60;
endx=600;
endy=380;
setfillstyle(1,15);
bar(0,0,640,480);
setfillstyle(1,7);
bar(0,endy+50,640,480);
win(0,0,640,starty-11,1);
setcolor(0);
rectangle(startx-49,starty-12,endx+39,endy+51);
settextstyle(2,0,4);
setcolor(15);
}
//**********************************************************************
********//
READ CURRENT DIRECTORY & DISPLAY FILES,FOLDERS
//**********************************************************************
********//
void ReadDirc()
{
struct ffblk ffblk;
char *Wildcard;
int done,x,y,dx,dy;
x=startx;y=starty;
dx=80;
dy=50;
Wildcard="*.bmp";// change wildcard (like : *.exe, *.cpp,a*.c?? etc)
done = findfirst(Wildcard,&ffblk,FA_DIREC);
while (!done)
{
if(ffblk.ff_name[0]!='.')
{
if(ffblk.ff_attrib==FA_DIREC)
Show(x,y,ffblk.ff_name,FOLDER);
else
Show(x,y,ffblk.ff_name,FILE1);
x+=dx;
if(x>=endx)
{
y+=dy;
x=startx;
}
if(y>=endy)
{
getch();
y=starty;
x=startx;
setfillstyle(1,15);
bar(startx-25,starty-10,endx+35,endy+35);
}
}
done = findnext(&ffblk);
}
}
//**********************************************************************
********//
DISPLAY SPECIFIED ICON
//**********************************************************************
********//
void Icon(int x,int y,int type)
{
unsigned color,size,i;
char *ext;
color=14;
size=25;
if(type==FOLDER)
{
setcolor(color);
for(i=1;i<=4;i++)
line(x+3-i,y+i,x+10+i,y+i);
setcolor(0);
line(x+3,y,x+10,y);
line(x+3,y,x,y+4);
line(x+10,y,x+14,y+4);
y+=4;
setfillstyle(1,color);
bar(x,y,x+size,y+size-(size/3));
setcolor(0);
rectangle(x,y,x+size,y+size-(size/3));
}
else if(type==FILE1)
{
setfillstyle(1,15);
bar(x+2,y+2,x+size-2,y+size-2);
setcolor(0);
rectangle(x+2,y+2,x+size-2,y+size-2);
setcolor(15);
line(x+2,y+2,x+6,y+2);// --
line(x+2,y+2,x+2,y+6);// |
setcolor(0);
line(x+6,y+2,x+2,y+6);// /
line(x+2,y+6,x+6,y+6);// --
line(x+6,y+2,x+6,y+6);// |
for(i=0;i<8;i++) line(x+6,y+5+i*2,x+size-6,y+5+i*2);
}
else if(type==EXE || type==COM || type==BAT)
{
if(type==EXE) ext="exe";
else if(type==COM) ext="com";
else ext="bat";
setfillstyle(1,1);
bar(x,y,x+size,y+size);
setfillstyle(1,15);
bar(x+2,y+8,x+size-2,y+size-2);
setcolor(7);
rectangle(x+2,y+1,x+size-2,y+6);
setcolor(9);
settextstyle(2,0,4);
settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(x+5,y+10,ext);
putpixel(x+size-5,y+3,14);
putpixel(x+size-7,y+3,14);
putpixel(x+size-9,y+3,14);
setcolor(0);
}
}
//**********************************************************************
********//
DISPLAY ICON & SHOW FILE NAME
//**********************************************************************
********//
void InitScreen(void)
{
union REGS r;
r.h.ah = 0;
r.h.al = 0x13;
int86(0x10, &r, &r);
return;
}
void ReadHeader(void)
{
int i,red[256],green[256],blue[256];
union REGS rin,rout;
//Read in header information
fread (&Header, 54, 1, gInpFile);
//Read in palette information
if(Header.bfOffBits==1078)
for(i=0;i<1024;i++)
c=fgetc(gInpFile);
return;
}
void ReadImg(void)
{
union REGS rin,rout;
int i,j;
/* displaying the original image */
{
ext[t]=fn1[3-t];
}
if(strcmpi("exe",ext)==0) return EXE;
if(strcmpi("bat",ext)==0) return BAT;
if(strcmpi("com",ext)==0) return COM;
//like this more extensions can be added
return 0;
}
//**********************************************************************
********//
DISPLAY WINDOW
//**********************************************************************
********//
void win(int sx,int sy,int ex,int ey,int ck)
{
setfillstyle(1,7);
bar(sx,sy,ex,ey);
setfillstyle(1,7);
setcolor(15);
line(sx,sy,sx,ey);
line(sx,sy,ex,sy);
line(sx,sy,sx,ey);
line(sx,sy,ex,sy);
setcolor(0);
line(ex,sy,ex,ey);
line(ex,sy,ex,ey);
line(sx,ey,ex,ey);
line(sx,ey,ex,ey);
if(ck==1)
{
settextstyle(0,0,0);
setfillstyle(1,1);
bar(sx+2,sy+2,ex-2,sy+17);
setcolor(15);
outtextxy(sx+4,sy+4,text);
//for x
setfillstyle(1,7);
bar(ex-15,sy+4,ex-4,sy+15);
setcolor(15);
line(ex-15,sy+4,ex-4,sy+4);
line(ex-15,sy+4,ex-15,sy+15);
setcolor(0);
line(ex-15,sy+15,ex-4,sy+15);
line(ex-4,sy+4,ex-4,sy+15);
setcolor(1);
outtextxy(ex-13,sy+5,"x");
setfillstyle(1,7);
}
}
//**********************************************************************
********//
GET CURRENT DIRECTORY
//**********************************************************************
********//
char *get_direc(char *tgt)
{
strcpy(tgt, "X:\\");
tgt[0] = 'A' + getdisk();
getcurdir(0,tgt+3);
return(tgt);
}
void func1(char* argv)
{ clrscr();
printf("********************************************************\n");
printf("\t\tDISPLAYING A BMP FILE\n");
printf("********************************************************\n\n");
gInpFile = fopen(argv,"rb");
if(gInpFile==NULL)
{
printf("File not found.");
getch();
exit(0);
}
printf("Press any key to view %s",argv[1]);
getch();
InitScreen();
ReadHeader();
ReadImg();
getch();
}