[問題] 新手讀bmp 的每點rgb
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev C++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
no
問題(Question):
24位元的bmp
因為我用fstream 來寫開讀檔 跟大家用file = =a 不太一樣
所以標頭讀完後 = 口= 我就不知道也怎讀取rgb了
typedef struct bmpinfoheader
{
unsigned long bmpInfoSize;//Bitmap Info Header 的長度
unsigned long bmpWidth; //寬
unsigned long bmpHeight;//高(長)
unsigned short bmpPlanes;//點陣圖的位元圖層數 ;
unsigned short bmpBitPixel;//每個像素的位元數
unsigned long bmpCompression;//壓縮方式
unsigned long bmpDataSize;
unsigned long bmpXplan;//x方向 水平
unsigned long bmpYplan;//y 方向 垂直
unsigned long bmpColorUsed;//使用顏色數
unsigned long bmpColorImportant;//重要顏色數
} ;
typedef struct RGB
{
unsigned char b;
unsigned char g;
unsigned char r;
unsigned char reserved;
};
int main ()
{
open_file();
system("pause");
}
int open_file()
{
bmpfileheader fhd;
bmpinfoheader ihd;
RGB color;
fstream file ; //宣告fstream物件
file.read((char*)&ihd.bmpColorImportant,4);
cout<<"imp color:"<<ihd.bmpColorImportant<<endl;
//這是info head 重要顏色 接下來就不會寫讀取RGB了
//有想過 file.read((char*)&color.b,1) 來讀左下第一個b值或改3硬bgr
印出來cout<<"b:"<<color.b<<endl;卻沒東西Q0Q
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.34.109.77
※ 編輯: pigcat1315 來自: 114.34.109.77 (08/05 15:01)
※ 編輯: pigcat1315 來自: 114.34.109.77 (08/05 15:02)
→
08/05 15:02, , 1F
08/05 15:02, 1F
→
08/05 15:13, , 2F
08/05 15:13, 2F
→
08/05 15:20, , 3F
08/05 15:20, 3F
→
08/05 15:41, , 4F
08/05 15:41, 4F
→
08/05 15:47, , 5F
08/05 15:47, 5F
→
08/05 15:53, , 6F
08/05 15:53, 6F
→
08/05 15:58, , 7F
08/05 15:58, 7F
→
08/05 16:05, , 8F
08/05 16:05, 8F
→
08/05 16:21, , 9F
08/05 16:21, 9F
→
08/05 16:41, , 10F
08/05 16:41, 10F
→
08/05 16:58, , 11F
08/05 16:58, 11F
→
08/05 16:59, , 12F
08/05 16:59, 12F
→
08/05 17:10, , 13F
08/05 17:10, 13F
→
08/05 17:11, , 14F
08/05 17:11, 14F
→
08/05 17:12, , 15F
08/05 17:12, 15F
→
08/05 17:13, , 16F
08/05 17:13, 16F
→
08/05 17:14, , 17F
08/05 17:14, 17F
→
08/05 17:15, , 18F
08/05 17:15, 18F
→
08/05 17:17, , 19F
08/05 17:17, 19F
→
08/05 17:45, , 20F
08/05 17:45, 20F
→
08/05 17:45, , 21F
08/05 17:45, 21F
→
08/05 17:47, , 22F
08/05 17:47, 22F
→
08/05 17:47, , 23F
08/05 17:47, 23F
→
08/05 17:55, , 24F
08/05 17:55, 24F
→
08/05 17:57, , 25F
08/05 17:57, 25F
→
08/05 19:09, , 26F
08/05 19:09, 26F
→
08/05 19:09, , 27F
08/05 19:09, 27F
→
08/05 19:10, , 28F
08/05 19:10, 28F
→
08/05 19:14, , 29F
08/05 19:14, 29F
→
08/05 19:33, , 30F
08/05 19:33, 30F
→
08/05 19:36, , 31F
08/05 19:36, 31F
→
08/05 19:36, , 32F
08/05 19:36, 32F
→
08/05 19:37, , 33F
08/05 19:37, 33F
→
08/05 19:39, , 34F
08/05 19:39, 34F
→
08/05 19:40, , 35F
08/05 19:40, 35F
※ 編輯: pigcat1315 來自: 114.34.109.77 (08/05 23:43)
※ 編輯: pigcat1315 來自: 114.34.109.77 (08/05 23:45)
→
08/05 23:46, , 36F
08/05 23:46, 36F
→
08/05 23:47, , 37F
08/05 23:47, 37F
※ 編輯: pigcat1315 來自: 114.34.109.77 (08/06 00:59)
討論串 (同標題文章)
完整討論串 (本文為第 1 之 3 篇):
問題
0
37