91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6.55MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-09-24
  • 語言: C/C++
  • 標簽: BMP??JPEG??C++??

資源簡介

C++代碼,支持圖pain從BMP格式轉換為JPEG格式,已經封裝好的C++ CBmp2Jpeg類,可直接調用: CBmp2Jpeg bmp; bmp.Bmp2Jpeg("111_24.bmp", "lena.jpg"); cout<<"good job."<<endl; cin.get(); return 0;

資源截圖

代碼片段和文件信息

#include?
#include
#include?
//#include
#include?“Bmp2Jpeg.h“
#include?

extern?“C“
{
#include?“jpeglib.h“
};

#pragma?comment(lib“libjpeg.lib“)

using?namespace?std;

#pragma?pack(2)??

struct?bmp_fileheader???//文件頭,長度為14Byte固定??
{??
unsigned?short?bfType;??
unsigned?long?bfSize;??
unsigned?short?bfReserved1;??
unsigned?short?bfReserved2;??
unsigned?long?bfOffBits;??
};??

struct?bmp_infoheader??//文件信息頭,長度為40Byte固定??
{??
unsigned?long?biSize;??
unsigned?long?biWidth;??
unsigned?long?biHeight;??
unsigned?short?biPlanes;??
unsigned?short?biBitCount;??
unsigned?long?biCompression;??
unsigned?long?biSizeImage;??
unsigned?long?biXPelsPerMeter;??
unsigned?long?biYPelsPerMeter;??
unsigned?long?biClrUsed;??
unsigned?long?biClrImportant;??
};?

struct?RGBPallete
{
unsigned?char?b;
unsigned?char?g;
unsigned?char?r;
unsigned?char?alpha;
};

CBmp2Jpeg::CBmp2Jpeg()?:
m_quality(JPEG_QUALITY)
{

}

CBmp2Jpeg::~CBmp2Jpeg()
{

}
/*===================================================================================
function:???????jpeg壓縮
input:??????????1:生成的文件名2:bmp的指針3:位圖寬度4:位圖高度5:顏色深度
return:?????????int
description:????bmp的像素格式為(RGB)
===================================================================================*/
int?CBmp2Jpeg::SaveJpeg(const?char?*filename?unsigned?char?*bits?int?width?int?height?int?depth)
{
FILE?*?outfile;?????????????????/*?target?file?*/
fopen_s(&outfile?filename?“wb“);
if?(outfile?==?NULL)?{
return?-1;
}

struct?jpeg_compress_struct?cinfo;
struct?jpeg_error_mgr?jerr;

cinfo.err?=?jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);

jpeg_stdio_dest(&cinfo?outfile);

cinfo.image_width?=?width;??????/*?image?width?and?height?in?pixels?*/
cinfo.image_height?=?height;
cinfo.input_components?=?3;?????????/*?#?of?color?components?per?pixel?*/
cinfo.in_color_space?=?JCS_RGB;?????????/*?colorspace?of?input?image?*/

jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo?m_quality?TRUE?/*?limit?to?baseline-JPEG?values?*/);

jpeg_start_compress(&cinfo?TRUE);

JSAMPROW?row_pointer[1];????????/*?pointer?to?JSAMPLE?row[s]?*/
int?????row_stride;?????????????/*?physical?row?width?in?image?buffer?*/
row_stride?=?width?*?depth;?/*?JSAMPLEs?per?row?in?image_buffer?*/

while?(cinfo.next_scanline? //這里我做過修改,由于jpg文件的圖像是倒的,所以改了一下讀的順序
//row_pointer[0]?=?&?bits[cinfo.next_scanline?*?row_stride];
row_pointer[0]?=?&?bits[(cinfo.image_height?-?cinfo.next_scanline?-?1)?*?row_stride];
(void)?jpeg_write_scanlines(&cinfo?row_pointer?1);
}

jpeg_finish_compress(&cinfo);
fclose(outfile);

jpeg_destroy_compress(&cinfo);
return?0;
}

void?CBmp2Jpeg::InitFileHeader(void?*pFile?void?*fileHeader)
{
bmp_fileheader?*pfileHeader?=?(bmp_fileheader?*)fileHeader;
fstream?*filein?=?(fstream?*)pFile;
//初始化文件頭
pfileHeader-

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????..A..H.?????33280??2018-05-22?10:06??Bmp2jpeg\.vs\Bmp2jpeg\v14\.suo

?????文件????6220854??2017-06-22?11:19??Bmp2jpeg\Bmp2jpeg\111_24.bmp

?????文件?????276598??2017-06-22?10:59??Bmp2jpeg\Bmp2jpeg\16.bmp

?????文件????2211894??2017-06-22?10:57??Bmp2jpeg\Bmp2jpeg\2017622105730.bmp

?????文件????2211894??2017-06-22?11:00??Bmp2jpeg\Bmp2jpeg\24.bmp

?????文件?????554038??2017-06-22?11:00??Bmp2jpeg\Bmp2jpeg\256.bmp

?????文件???????7690??2017-06-22?11:31??Bmp2jpeg\Bmp2jpeg\Bmp2Jpeg.cpp

?????文件????????723??2017-06-22?11:31??Bmp2jpeg\Bmp2jpeg\Bmp2Jpeg.h

?????文件???????4224??2017-06-22?13:50??Bmp2jpeg\Bmp2jpeg\Bmp2jpeg.vcxproj

?????文件???????1155??2017-06-22?13:50??Bmp2jpeg\Bmp2jpeg\Bmp2jpeg.vcxproj.filters

?????文件????????143??2017-06-22?10:48??Bmp2jpeg\Bmp2jpeg\Bmp2jpeg.vcxproj.user

?????文件??????????3??2018-05-22?10:05??Bmp2jpeg\Bmp2jpeg\Debug\Bmp2jpeg.log

?????文件????1335146??2017-06-22?13:54??Bmp2jpeg\Bmp2jpeg\lena.jpg

?????文件???????3704??2017-06-22?13:54??Bmp2jpeg\Bmp2jpeg\main.cpp

?????文件????????891??2017-06-22?10:48??Bmp2jpeg\Bmp2jpeg.sln

????..A..H.?????13824??2017-06-22?14:33??Bmp2jpeg\Bmp2jpeg.suo

?????文件???15269888??2017-06-22?10:50??Bmp2jpeg\ipch\bmp2jpeg-ab62d05f\bmp2jpeg-17e0ff43.ipch

?????文件???????5992??2017-04-05?16:18??Bmp2jpeg\jpeglib\jconfig.h

?????文件??????15371??2017-04-05?16:18??Bmp2jpeg\jpeglib\jmorecfg.h

?????文件??????50461??2017-04-05?16:18??Bmp2jpeg\jpeglib\jpeglib.h

?????文件?????835192??2017-04-05?16:18??Bmp2jpeg\jpeglib\libjpeg.lib

?????文件???????1063??2017-04-05?16:18??Bmp2jpeg\jpeglib\readme.txt

?????目錄??????????0??2018-05-22?10:03??Bmp2jpeg\.vs\Bmp2jpeg\v14

?????目錄??????????0??2018-05-22?10:03??Bmp2jpeg\.vs\Bmp2jpeg

?????目錄??????????0??2018-05-22?10:05??Bmp2jpeg\Bmp2jpeg\Debug

?????目錄??????????0??2017-08-08?14:47??Bmp2jpeg\ipch\bmp2jpeg-ab62d05f

????...D.H.?????????0??2018-05-22?10:03??Bmp2jpeg\.vs

?????目錄??????????0??2017-08-08?14:47??Bmp2jpeg\Bmp2jpeg

?????目錄??????????0??2018-05-22?10:05??Bmp2jpeg\Debug

?????目錄??????????0??2017-08-08?14:47??Bmp2jpeg\ipch

............此處省略5個文件信息

評論

共有 條評論