| | |
256 color bmp in turbo c++ 3.0
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
how to display 256 color bmp files in trubo c++ 3.0??? i ve already displayed a 16 color bitmap in turbo c++...
i came across this code but it doesnt work...pls tell me whts the error...
PS-
1. i have svga256.bgi in c:\\tc\\bgi...do i need sum other files??
2. this is to be used in my skool project...n i asked my teacher n she said u cant use allegero,fastgraph or ne other compiler...i HAVE to use turbo c++ onli<sigh>
3."ab.bmp"(file i m trying to open) is attached with this msg
4.when i try to run the code...if i use show(),i get a completely destroyed form of the pic...its worse thn wht i get by displaying 16 colors... if i use show1(),i get the same output but this tym its inverted also...pls help!!!!!!!!!
i came across this code but it doesnt work...pls tell me whts the error...
C++ Syntax (Toggle Plain Text)
#include<iostream.h> #include<graphics.h> #include<fstream.h> #include<conio.h> struct A{ char type[2]; /* Magic identifier */ unsigned long size; /* File size in bytes */ unsigned short int reserved1, reserved2; unsigned long offset; /* Offset to image data, bytes */ }HEADER,HEADER1; struct B{ unsigned long size; /* Header size in bytes */ unsigned long width,height; /* Width and height of image */ unsigned short int planes; /* Number of colour planes */ unsigned short int bits; /* Bits per pixel */ unsigned long compression; /* Compression type */ unsigned long imagesize; /* Image size in bytes */ unsigned long xresolution,yresolution; /* Pixels per meter */ unsigned long ncolours; /* Number of colours */ unsigned long importantcolours; /* Important colours */ }INFOHEADER,INFOHEADER1; huge DetectSvga() { return 2; } void Show() { fstream File; File.open("c:\\tc\\bin\\tet.bmp",ios::in); char Ch; File.read((char*)&HEADER,14); //This is the header part of the Bitmap. File.read((char*)&INFOHEADER,40); //This is another part of the bitmap unsigned int i; char ColorBytes[4]; char*PaletteData; PaletteData=new char[256*3]; if(PaletteData)//if memory allocated successfully { //read color data for(i=0;i<256;i++) { //pls xplain wht this part does..i don understand it fully File.read(ColorBytes,4); PaletteData[(int)(i*3+2)]=ColorBytes[0]>>2; PaletteData[(int)(i*3+1)]=ColorBytes[1]>>2; PaletteData[(int)(i*3+0)]=ColorBytes[2]>>2; } outp(0x03c8,0); //tell DAC that data is coming for(i=0;i<256*3;i++) //send data to SVGA DAC { outp(0x03c9,PaletteData[i]); } delete[]PaletteData; } for(i=0;i<INFOHEADER.height;i++) //This for loop is used to display the bitmap. { for(int j=0;j<INFOHEADER.width;) { File.read(&Ch,1); // Here Ch reads the color of your bitmap. putpixel(0+(j++),0+INFOHEADER.height-i-1,Ch); } } File.close(); } void Show1() { char Ch; fstream File; File.open("c:\\tc\\bin\\ab.bmp",ios::in); File.seekg(54,ios::beg); File.seekg(256*4,ios::cur); for(int i=0;i<214;i++) { for(int j=0;j<356;j++) { File.read(&Ch,1); //Here Ch is the character which reads the color of your bitmap. putpixel(10+j,10+39+i,Ch); } } } void main() { clrscr(); int gd = DETECT, md, a; initgraph(&gd,&md,"c:\\tc\\bgi"); //Path may be different in your computer. installuserdriver("svga256",&DetectSvga); Show(); getch(); setcolor(BLACK); setfillstyle(1,0); bar(0,0,640,480);//clears the screen..cant use clrscr() as den myscreen turns grey Show1(); getch(); }
PS-
1. i have svga256.bgi in c:\\tc\\bgi...do i need sum other files??
2. this is to be used in my skool project...n i asked my teacher n she said u cant use allegero,fastgraph or ne other compiler...i HAVE to use turbo c++ onli<sigh>
3."ab.bmp"(file i m trying to open) is attached with this msg
4.when i try to run the code...if i use show(),i get a completely destroyed form of the pic...its worse thn wht i get by displaying 16 colors... if i use show1(),i get the same output but this tym its inverted also...pls help!!!!!!!!!
Or get a real compiler!!!!
> this is to be used in my skool project...n i asked my teacher n she said u cant use allegero,fastgraph or ne other compiler
Scratch that, get a real teacher instead.
They don't know C any better than you do. They "learnt" some tricks for TurboC 20 years ago, and are now too scared to update to another compiler because all that they know is in fact useless.
Which in turn means that all that YOU will know will in fact be useless.
> this is to be used in my skool project...n i asked my teacher n she said u cant use allegero,fastgraph or ne other compiler
Scratch that, get a real teacher instead.
They don't know C any better than you do. They "learnt" some tricks for TurboC 20 years ago, and are now too scared to update to another compiler because all that they know is in fact useless.
Which in turn means that all that YOU will know will in fact be useless.
skandh,
Your question should be - How to display 256 color bitmap using C++ program?
Use C99 - standard c++ compiler. CodeBlocks, DevC++, and Microsoft Visual C++ are free compilers.
Read more about C-99
http://www.open-std.org/jtc1/sc22/wg14/
http://siddhant3s.googlepages.com/ho...usted_cpp.html
https://developer.mozilla.org/en/C___Portability_Guide
Your question should be - How to display 256 color bitmap using C++ program?
Use C99 - standard c++ compiler. CodeBlocks, DevC++, and Microsoft Visual C++ are free compilers.
Read more about C-99
http://www.open-std.org/jtc1/sc22/wg14/
http://siddhant3s.googlepages.com/ho...usted_cpp.html
https://developer.mozilla.org/en/C___Portability_Guide
Last edited by adatapost; Jul 19th, 2009 at 8:13 am.
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
hey...thnk u sooo much...all ur replies were really helpful specially the last one..but one more thing...is using dev c++ REALLY THT simple???
fr eg- for loading a bmp file,is dere ne command lyk
???
fr eg- for loading a bmp file,is dere ne command lyk
C++ Syntax (Toggle Plain Text)
loadbitmap(x_cord,y_cord,filename);
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
***this is fr other CBSE guys who have the same problem***
i just solved the prob...i successfully displayed 256 color bitmap in turbo C++ 3.0....i m so tempted to post the code but its against the rules...so i cant
but ill c if i cn upload the code in snippets section...
btw, i used mode13h n bitmap headers..google fr it...
i just solved the prob...i successfully displayed 256 color bitmap in turbo C++ 3.0....i m so tempted to post the code but its against the rules...so i cant

but ill c if i cn upload the code in snippets section...
btw, i used mode13h n bitmap headers..google fr it...
I thought you wanted help with graphics, not cryptography.
Oh wait, it's not encrypted, it's drivel-speak
http://www.catb.org/~esr/faqs/smart-...html#writewell
Oh wait, it's not encrypted, it's drivel-speak
http://www.catb.org/~esr/faqs/smart-...html#writewell
![]() |
Similar Threads
- Changing a pixel color that is "close" to another color (Pascal and Delphi)
- Turbo C doubt (C++)
- help me plzzz..Turbo C (C++)
- How to display graphics in 256 color in C (C)
- cannot get 256 color to apply to my monitor i dont know what to do (Windows 95 / 98 / Me)
- images no longer animated (Web Browsers)
- svga drivers..video problems (Windows 95 / 98 / Me)
Other Threads in the C++ Forum
- Previous Thread: c++ OOP Mortgage Calculator
- Next Thread: Can someone spot my iosflag error?
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui iamthwee ifstream input int java lib library lines linkedlist linker loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return sort string strings struct studio system temperature template templates test text text-file tree unix url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






