256 color bmp in turbo c++ 3.0

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2009
Posts: 7
Reputation: skandh has a little shameless behaviour in the past 
Solved Threads: 0
skandh skandh is offline Offline
Newbie Poster

256 color bmp in turbo c++ 3.0

 
0
  #1
Jul 19th, 2009
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...
  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<fstream.h>
  4. #include<conio.h>
  5. struct A{
  6. char type[2]; /* Magic identifier */
  7. unsigned long size; /* File size in bytes */
  8. unsigned short int reserved1, reserved2;
  9. unsigned long offset; /* Offset to image data, bytes */
  10. }HEADER,HEADER1;
  11. struct B{
  12. unsigned long size; /* Header size in bytes */
  13. unsigned long width,height; /* Width and height of image */
  14. unsigned short int planes; /* Number of colour planes */
  15. unsigned short int bits; /* Bits per pixel */
  16. unsigned long compression; /* Compression type */
  17. unsigned long imagesize; /* Image size in bytes */
  18. unsigned long xresolution,yresolution; /* Pixels per meter */
  19. unsigned long ncolours; /* Number of colours */
  20. unsigned long importantcolours; /* Important colours */
  21. }INFOHEADER,INFOHEADER1;
  22.  
  23. huge DetectSvga()
  24. {
  25. return 2;
  26. }
  27.  
  28. void Show()
  29. {
  30. fstream File;
  31. File.open("c:\\tc\\bin\\tet.bmp",ios::in);
  32. char Ch;
  33. File.read((char*)&HEADER,14); //This is the header part of the Bitmap.
  34. File.read((char*)&INFOHEADER,40); //This is another part of the bitmap
  35. unsigned int i;
  36. char ColorBytes[4];
  37. char*PaletteData;
  38.  
  39. PaletteData=new char[256*3];
  40.  
  41. if(PaletteData)//if memory allocated successfully
  42. {
  43. //read color data
  44. for(i=0;i<256;i++)
  45. {
  46. //pls xplain wht this part does..i don understand it fully
  47. File.read(ColorBytes,4);
  48. PaletteData[(int)(i*3+2)]=ColorBytes[0]>>2;
  49. PaletteData[(int)(i*3+1)]=ColorBytes[1]>>2;
  50. PaletteData[(int)(i*3+0)]=ColorBytes[2]>>2;
  51. }
  52.  
  53. outp(0x03c8,0); //tell DAC that data is coming
  54.  
  55. for(i=0;i<256*3;i++) //send data to SVGA DAC
  56. {
  57. outp(0x03c9,PaletteData[i]);
  58. }
  59. delete[]PaletteData;
  60. }
  61.  
  62. for(i=0;i<INFOHEADER.height;i++) //This for loop is used to display the bitmap.
  63. {
  64. for(int j=0;j<INFOHEADER.width;)
  65. {
  66. File.read(&Ch,1); // Here Ch reads the color of your bitmap.
  67. putpixel(0+(j++),0+INFOHEADER.height-i-1,Ch);
  68.  
  69. }
  70. }
  71.  
  72. File.close();
  73.  
  74. }
  75. void Show1()
  76. {
  77.  
  78. char Ch;
  79. fstream File;
  80. File.open("c:\\tc\\bin\\ab.bmp",ios::in);
  81. File.seekg(54,ios::beg);
  82. File.seekg(256*4,ios::cur);
  83. for(int i=0;i<214;i++)
  84. {
  85. for(int j=0;j<356;j++)
  86. {
  87. File.read(&Ch,1); //Here Ch is the character which reads the color of your bitmap.
  88. putpixel(10+j,10+39+i,Ch);
  89. }
  90. }
  91. }
  92. void main()
  93. {
  94. clrscr();
  95. int gd = DETECT, md, a;
  96. initgraph(&gd,&md,"c:\\tc\\bgi"); //Path may be different in your computer.
  97. installuserdriver("svga256",&DetectSvga);
  98. Show();
  99. getch();
  100. setcolor(BLACK);
  101. setfillstyle(1,0);
  102. bar(0,0,640,480);//clears the screen..cant use clrscr() as den myscreen turns grey
  103. Show1();
  104. getch();
  105.  
  106. }

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!!!!!!!!!
Attached Images
File Type: bmp ab.bmp (75.5 KB, 5 views)
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 476
Reputation: csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice csurfer is just really nice 
Solved Threads: 76
csurfer's Avatar
csurfer csurfer is offline Offline
Posting Pro in Training

Re: 256 color bmp in turbo c++ 3.0

 
0
  #2
Jul 19th, 2009
Try installing the lib folder again... from some other copy...Its a common problem in TC...you wont have that problem again once you replace that folder with the proper ones.
I Surf in "C"....
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: 256 color bmp in turbo c++ 3.0

 
1
  #3
Jul 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 501
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: 256 color bmp in turbo c++ 3.0

 
1
  #4
Jul 19th, 2009
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
Last edited by adatapost; Jul 19th, 2009 at 8:13 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: skandh has a little shameless behaviour in the past 
Solved Threads: 0
skandh skandh is offline Offline
Newbie Poster

Re: 256 color bmp in turbo c++ 3.0

 
0
  #5
Jul 19th, 2009
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
  1. loadbitmap(x_cord,y_cord,filename);
???
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,721
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 501
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven
Join Date: Jul 2009
Posts: 7
Reputation: skandh has a little shameless behaviour in the past 
Solved Threads: 0
skandh skandh is offline Offline
Newbie Poster

Re: 256 color bmp in turbo c++ 3.0

 
0
  #7
Jul 31st, 2009
***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...
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: skandh has a little shameless behaviour in the past 
Solved Threads: 0
skandh skandh is offline Offline
Newbie Poster

Re: 256 color bmp in turbo c++ 3.0

 
0
  #8
Aug 6th, 2009
but one small prob....the size i get is 320x200...i noe deres no way i cn get 640x480 in mode13h...so the prob remains...still cant get 640x320x256 in turbo c++ 3.0...
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: 256 color bmp in turbo c++ 3.0

 
0
  #9
Aug 6th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: skandh has a little shameless behaviour in the past 
Solved Threads: 0
skandh skandh is offline Offline
Newbie Poster

Re: 256 color bmp in turbo c++ 3.0

 
-1
  #10
Aug 10th, 2009
o wow!! u r so funi!!!!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC