Add to Favorites    Make Home Page 14539 Online  
 Language Categories  
 Our Services  

Home » C Home » Data Structures Home » BitmapViewer (Mini Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title BitmapViewer (Mini Project)
Author Bhagavath Chidhambaram
Author Email pachidhambaram [at] yahoo.com
Description This program is used to view the bitmap files.
Category C » Data Structures
Hits 393871
Code Select and Copy the Code
/* B.Chidhambaram M.Sc.Software Engg, Final Year Noorul Islam College of Engg Mobile No : 9894586845 */ #include<stdio.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<string.h> /* mouse.h */ union REGS i,o; void InitMouse(); void ShowMousePtr(); void GetMousePos(int*,int*,int*); void HideMousePtr(); void RestoreMousePtr(); void RestrictMousePtr(int, int, int, int); void SetMousePtr(int , int); void InitMouse() { i.x.ax = 0; int86(0x33,&i, &o); } void ShowMousePtr() { i.x.ax = 1; int86(0x33, &i, &o); } void HideMousePtr() { i.x.ax = 2; int86(0x33, &i, &o); } void GetMousePos(int button[1], int x[1], int y[1]) { i.x.ax = 3; int86(0x33, &i, &o); button[0]=o.x.bx; x[0]=o.x.cx; y[0]=o.x.dx; } void RestoreMousePtr() { i.x.ax = 7; i.x.cx = 0; i.x.dx = 79*8; int86(0x33, &i, &o); i.x.ax = 8; i.x.cx = 0; i.x.dx = 24*8; int86(0x33, &i, &o); } void RestrictMousePtr(int x1, int y1, int x2, int y2) { i.x.ax = 7; i.x.cx = x1; i.x.dx = x2; int86(0x33, &i, &o); i.x.ax = 8; i.x.cx = y1; i.x.dx = y2; int86(0x33, &i, &o); } void SetMousePtr(int x, int y) { i.x.ax = 4; i.x.cx = x; i.x.dx = y; int86(0x33, &i, &o); } /*bmps.h*/ char *FileName; FILE *fpImage; long Size; unsigned char *PixelArray; //for Image pixel values typedef struct tagBITMAPFILEHEADER { char bfType[2]; //Bmp File Type long bfSize; //Total File Size int bfReserved1; //Not For Programmers int bfReserved2; //Not For Programmers long bfOffBits; //Starting Position Of Data }; typedef struct tagBITMAPINFOHEADER { long biSize; //Structure Size long biWidth; //Bmp Width long biHeight; //Bmp Height int biPlanes; int biBitCount; //No Of Bits Used long biCompression; long biSizeImage; //Bmp Total Size long biXPelsPerMeter; long biYPelsPerMeter; long biClrUsed; long biClrImportant; }; typedef struct tagRGBQUAD { unsigned char rgbBlue; //Blue Color Value unsigned char rgbGreen; //Green Color Value unsigned char rgbRed; //Red Color Value unsigned char rgbReserved ; //Not For Programmer's Use }; typedef struct tagBITMAPINFO { struct tagBITMAPINFOHEADER bmiHeader; //Bmp Information area struct tagRGBQUAD bmiColors[256]; //Color Table Entries }; struct tagBITMAPFILEHEADER bmpFileHeader; struct tagBITMAPINFO bmpInfo; void SetGrayScale() //SetGrayScale { int i; struct palettetype pal; getpalette(&pal); for (i=0; i<pal.size; i++) setrgbpalette(pal.colors[i],i*4,i*4,i*4); } int Read(char *fname,char *oname) { int i,j; FileName = (char*)malloc(strlen(fname)+1); strcpy(FileName,fname); //File Open if((fpImage=fopen(FileName,"rb"))==NULL) { strcpy(oname,"Sorry. File not found !"); return 0; } //Read The BitMAP FILE HEADER if(fread(&bmpFileHeader,sizeof(struct tagBITMAPFILEHEADER),1,fpImage)==0) { strcpy(oname,"File Is A Currupted One"); return 0; } if(bmpFileHeader.bfType[0]!='B' || bmpFileHeader.bfType[1]!='M') { strcpy(oname,"File Is Not A Bitmap"); return 0; } //Read The BITMAP INFO HEADER if(fread(&(bmpInfo.bmiHeader),sizeof(struct tagBITMAPINFOHEADER),1,fpImage)==0) { strcpy(oname,"File Is A Corrupted One"); return 0; } //Reading Color Table for(i = 0 ;i<256;i++) if(fread(&(bmpInfo.bmiColors[i]),sizeof(struct tagRGBQUAD),1,fpImage)==0) { strcpy(oname,"File Is A Currupted One"); return -1; } strcpy(oname,"Image File is Loaded"); return 1; } void Display(char fname[]) { int i,j; char temp[30]; cleardevice(); SetGrayScale(); Read(fname,temp); PixelArray = (unsigned char*)malloc(sizeof(unsigned char*)); for(i=0;i<bmpInfo.bmiHeader.biHeight;i++) for(j=0;j<bmpInfo.bmiHeader.biWidth;j++) { fread(PixelArray,1,1,fpImage) ; putpixel(j,bmpInfo.bmiHeader.biHeight-i,*PixelArray/16); } fclose(fpImage); } char *Menus[]={" Load BMP File"," BMP Details"," View Image"," Exit Program"}; int FileLoaded=0; char *FileName; void Box(int x1,int y1,int x2,int y2) { rectangle(x1,y1,x2,y2); rectangle(x1+5,y1+5,x2-5,y2-5); setfillstyle(SOLID_FILL, 7); floodfill(x1+1,y2-4,8); } void TextBox(int x,int y,int len,char str[]) { char ch;int curr=0; setfillstyle(1,15); bar(x, y-3, x+len, y+23); setcolor(0); rectangle(x+1, y-2, x+len-1, y+22); settextstyle(6,0,1); HideMousePtr(); do { ch=getch(); str[curr]=ch; if(curr*14 < len) if(isalpha(ch)||isdigit(ch) ||ch=='.') if(curr>=0) curr++; if(curr > 0 && ch==8) { curr--; bar(x, y-3, x+len, y+23); rectangle(x+1, y-2, x+len-1, y+22); } str[curr]='

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=840


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review