本文主要是介绍C++:将六个tif分色片写成bmp格式图片(8位深),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#include <cv.h>
#include <highgui.h>
#include <iostream>
//#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include<opencv2/opencv.hpp>
//必须得加上,才可以使用imread、MAT等opencv功能
using namespace cv;
using namespace std;
#pragma pack(2)//必须得写,否则sizeof得不到正确的结果
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
typedef struct {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER;
typedef struct {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
typedef struct tagPALETTEENTRY { // pe
// bmp中RGB的存放顺序是BGR,如果此处不写对的话,颜色会错
BYTE peBlue;
BYTE peRed;
BYTE peGreen;
BYTE peFlags;
} PALETTEENTRY;
//void saveBitmap()
int main()
{
//FILE *fptest = fopen("F:/Desktop/写bmp/test.bmp", "wb+");
//if (fptest == NULL)
//{
// printf("file open failed.");
// exit(1);
//}
//BYTE *test = (BYTE *)malloc(8);
//test[0] = 255;
//test[1] = 128;
//test[2] = 0;
//test[3] = 255;
//test[4] = 255;
//test[5] = 255;
//test[6] = 255;
//test[7] = 255;
//fwrite(test, 8, 1, fptest);
//fclose(fptest);
//原来图片的大小
Mat KH = imread("F:/Desktop/写bmp/1KH.tif", 0);
Mat KL = imread("F:/Desktop/写bmp/1KL.tif", 0);
Mat CH = imre
这篇关于C++:将六个tif分色片写成bmp格式图片(8位深)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!