fork(1) download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4.  
  5. #define WORD short int
  6. #define DWORD long int
  7. #define LONG long int
  8.  
  9. using namespace std;
  10.  
  11. char *File1_Name ="0001.bmp";
  12. BITMAPFILEHEADER File1_F;
  13. BITMAPINFOHEADER File1_I;
  14. RGBQUAD File1_rgb[256];
  15. byte *File1_pixel;
  16.  
  17.  
  18.  
  19. char *File3_Name = "0003.bmp";
  20. byte *File3_pixel;
  21.  
  22. //-------主程式-----------------------------------------------------------------------------
  23. int main()
  24. {
  25. fstream file;
  26. int i,j,Size,Width,Height;
  27. char PIXEL[128][128],temp[128][128];
  28. ////////////////////////////////////////////////////
  29. //1. 影像matrix讀進來: *pixel 的大小為 (I.biWidth)X(I.biHeight)
  30. // 請你動態的new空間出來
  31. ////////////////////////////////////////////////////
  32.  
  33.  
  34. file.open(File1_Name,std::ios::in|std::ios::binary);
  35.  
  36. if(!file)
  37. {
  38. cout<<"open fail.\n";
  39. return 1;
  40. }
  41. file.read((char*)&File1_F, sizeof(BITMAPFILEHEADER));
  42. file.read((char*)&File1_I, sizeof(BITMAPINFOHEADER));
  43. file.read((char*)&File1_rgb, sizeof(File1_rgb));
  44. //讀取Image data
  45. file.close();
  46.  
  47. ////////////////////////////////////////////////////
  48. ///2. Show 檔頭資訊:
  49. //
  50. ////////////////////////////////////////////////////
  51.  
  52. Size=File1_F.bfSize;
  53. Width=File1_I.biWidth;
  54. Height=File1_I.biHeight;
  55.  
  56.  
  57. cout<<"BITMAPFILEHEADER\n\n";
  58. cout<<"File Size ="<<Size<<"\n";
  59. cout<<"BITMAPINFOHEADER\n\n";
  60. cout<<"WIDTH ="<<Width<<"\n";
  61. cout<<"HEIGHT ="<<Width<<"\n";
  62.  
  63.  
  64.  
  65. ////////////////////////////////////////////////////
  66. ///3. 影像處理: 改變矩陣內容
  67. //
  68. ////////////////////////////////////////////////////
  69. file.open(File3_Name,"r+b");
  70.  
  71.  
  72. for(i=0;i<=File1_I.biHeight;i++)
  73. {
  74. for(j=0;j<=File1_I.biWidth;j++)
  75. {
  76.  
  77. if(File1_rgb[256]>0)
  78. *File3_pixel= *File1_pixel;
  79.  
  80.  
  81. }
  82. }
  83.  
  84.  
  85.  
  86.  
  87. ////////////////////////////////////////////////////
  88. ///4. 影像matrix檔案寫出
  89. //
  90. ////////////////////////////////////////////////////
  91. /*fstream file3;
  92. file3.open(File3_Name,std::ios::out|std::ios::binary);
  93. file3.write((char*)&F, sizeof(BITMAPFILEHEADER));
  94. file3.write((char*)&I, sizeof(BITMAPINFOHEADER));
  95. file3.write((char*)&rgb, sizeof(rgb));
  96.   file3.write((char*)pixel, I.biWidth*I.biWidth);
  97. file3.close(); */
  98.  
  99.  
  100.  
  101. system("pause");
  102. return 0;
  103. }
  104.  
  105.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:22: error: windows.h: No such file or directory
prog.cpp:11: warning: deprecated conversion from string constant to ‘char*’
prog.cpp:12: error: ‘BITMAPFILEHEADER’ does not name a type
prog.cpp:13: error: ‘BITMAPINFOHEADER’ does not name a type
prog.cpp:14: error: ‘RGBQUAD’ does not name a type
prog.cpp:15: error: expected constructor, destructor, or type conversion before ‘*’ token
prog.cpp:19: warning: deprecated conversion from string constant to ‘char*’
prog.cpp:20: error: expected constructor, destructor, or type conversion before ‘*’ token
prog.cpp: In function ‘int main()’:
prog.cpp:41: error: ‘File1_F’ was not declared in this scope
prog.cpp:41: error: ‘BITMAPFILEHEADER’ was not declared in this scope
prog.cpp:42: error: ‘File1_I’ was not declared in this scope
prog.cpp:42: error: ‘BITMAPINFOHEADER’ was not declared in this scope
prog.cpp:43: error: ‘File1_rgb’ was not declared in this scope
prog.cpp:69: error: no matching function for call to ‘std::basic_fstream<char, std::char_traits<char> >::open(char*&, const char [4])’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/fstream:756: note: candidates are: void std::basic_fstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]
prog.cpp:78: error: ‘File3_pixel’ was not declared in this scope
prog.cpp:78: error: ‘File1_pixel’ was not declared in this scope
prog.cpp:101: error: ‘system’ was not declared in this scope
prog.cpp:27: warning: unused variable ‘PIXEL’
prog.cpp:27: warning: unused variable ‘temp’
stdout
Standard output is empty