资源简介
vc图像编程实例:jpeg格式转换成bmp
vc图像编程实例:jpeg格式转换成bmp
vc图像编程实例:jpeg格式转换成bmp
vc图像编程实例:jpeg格式转换成bmp
代码片段和文件信息
// jpegcompresstest.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
#include
extern “C“
{
#include “..\libjpeg\jpeglib.h“
}
BYTE srcBmpP[4096000];
//BYTE jpeg_buffer[409600]; //用于内存/
// unconditional swaps
#define Swap16(s) \
((short) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)))
#define Swap32(l) \
((int) ((((l) & 0xff000000) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24)))
void Screen(char filename[])
{
//获取当前整个屏幕DC
HDC hDC = GetDC(NULL);
//获得颜色模式
int BitPerPixel = GetDeviceCaps(hDC BITSPIXEL);
int Width = GetDeviceCaps(hDC HORZRES);
int Height = GetDeviceCaps(hDC VERTRES);
//创建与获得的CDC兼容的内存设备描述
HDC hMemDC = CreateCompatibleDC(hDC);
//建立和屏幕兼容的bitmap
HBITMAP hMemBitmap hOldMemBitmap;
//初始化memBitmap
hMemBitmap = CreateCompatibleBitmap(hDC Width Height);
//将memBitmap选入内存DC
hOldMemBitmap = (HBITMAP)Selectobject(hMemDC hMemBitmap);
//复制屏幕图像到内存DC
BitBlt(hMemDC0 0 Width Height hDC 0 0 SRCCOPY);
//以下代码保存hMemDC中的位图到文件
BITMAP bmp;
//获得位图信息
Getobject( hMemBitmap (int)sizeof(BITMAP) &bmp );
// FILE *fp = fopen(filename “w+b“);
//位图信息头
BITMAPINFOHEADER bih = {0};
//每个像素字节大小
bih.biBitCount = bmp.bmBitsPixel;
//无压缩
bih.biCompression = BI_RGB;
//高度
bih.biHeight = bmp.bmHeight;
bih.biPlanes = 1;
bih.biSize = sizeof(BITMAPINFOHEADER);
//图像数据大小
bih.biSizeImage = bmp.bmWidthBytes * bmp.bmHeight;
//宽度
bih.biWidth = bmp.bmWidth;
//位图文件头
BITMAPFILEHEADER bfh = {0};
//到位图数据的偏移量
bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
//文件总的大小
bfh.bfSize = bfh.bfOffBits + bmp.bmWidthBytes * bmp.bmHeight;
//字符“BM“,表示位图文件
bfh.bfType = (WORD)0x4d42;
//写入位图文件头
// fwrite(&bfh 1 sizeof(BITMAPFILEHEADER) fp);
//写入位图信息头
// fwrite(&bih 1 sizeof(BITMAPINFOHEADER) fp);
//申请内存保存位图数据
//BYTE * p = new BYTE[bmp.bmWidthBytes * bmp.bmHeight];
//获取位图数据
GetDIBits(hMemDC hMemBitmap 0 Height srcBmpP (LPBITMAPINFO) &bih DIB_RGB_COLORS);
//写入位图数据
// fwrite(srcBmpP 1 bmp.bmWidthBytes * bmp.bmHeight fp);
// delete [] p;
// fclose(fp);
Selectobject(hMemDC hOldMemBitmap);
}
int image_width = 1280; //不是固定需要获取
int image_height = 800; //不是固定需要获取
int bitsPerPixel = 32; //不是固定需要获取
BYTE *m_buffer = srcBmpP; //
int m_remoteformat_bitsPerPixel = 32;
//int m_usePixelFormat24 = false;
//static struct jpeg_destination_mgr jpegDstManager;
//static JOCTET *jpegDstBuffer;
//static size_t jpegDstBufferLen;
static bool jpegError;
//static int jpegDstDataLen;
//static void JpegInitDestination(j_compress_ptr cinfo);
//static boolean JpegEmptyOutputBuffer(j_compress_ptr cinfo);
//static void JpegTermDestination(j_compress_ptr cinfo);
//
//static void
//JpegInitDestination(j_compress_ptr cinfo)
//{
// jpegError = false;
// jpegDstManager.next_output_byte = jpeg
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2007-01-28 22:10 jpegcompresstest\debug
目录 0 2007-01-28 22:10 jpegcompresstest\jpegcompresstest\Debug
文件 8176 2007-01-28 22:05 jpegcompresstest\jpegcompresstest\jpegcompresstest.cpp
文件 4514 2007-01-28 15:43 jpegcompresstest\jpegcompresstest\jpegcompresstest.vcproj
文件 1427 2007-01-28 22:07 jpegcompresstest\jpegcompresstest\jpegcompresstest.vcproj.MICROSOF-B2A6F0.Administrator.user
文件 1004 2007-01-28 15:43 jpegcompresstest\jpegcompresstest\ReadMe.txt
文件 221 2007-01-28 15:43 jpegcompresstest\jpegcompresstest\stdafx.cpp
文件 276 2007-01-28 15:43 jpegcompresstest\jpegcompresstest\stdafx.h
目录 0 2007-01-28 22:05 jpegcompresstest\jpegcompresstest
文件 1527 2007-01-28 15:46 jpegcompresstest\jpegcompresstest.sln
文件 1565 2002-12-11 15:06 jpegcompresstest\libjpeg\ansi2knr.1
文件 23008 2002-12-11 15:06 jpegcompresstest\libjpeg\ansi2knr.c
文件 5381 2002-12-11 15:06 jpegcompresstest\libjpeg\cderror.h
文件 4863 2002-12-11 15:06 jpegcompresstest\libjpeg\cdjpeg.c
文件 6307 2002-12-11 15:06 jpegcompresstest\libjpeg\cdjpeg.h
文件 9501 2002-12-11 15:06 jpegcompresstest\libjpeg\change.log
文件 10418 2002-12-11 15:06 jpegcompresstest\libjpeg\cjpeg.1
文件 20458 2002-12-11 15:06 jpegcompresstest\libjpeg\cjpeg.c
文件 12568 2002-12-11 15:06 jpegcompresstest\libjpeg\ckconfig.c
文件 25163 2002-12-11 15:06 jpegcompresstest\libjpeg\config.guess
文件 20756 2002-12-11 15:06 jpegcompresstest\libjpeg\config.sub
文件 62320 2002-12-11 15:06 jpegcompresstest\libjpeg\configure
目录 0 2007-01-28 22:10 jpegcompresstest\libjpeg\Debug
文件 7669 2002-12-11 15:06 jpegcompresstest\libjpeg\djpeg.1
文件 19955 2002-12-11 15:06 jpegcompresstest\libjpeg\djpeg.c
文件 17524 2002-12-11 15:06 jpegcompresstest\libjpeg\example.c
文件 5834 2002-12-11 15:06 jpegcompresstest\libjpeg\install-sh
文件 9401 2002-12-11 15:06 jpegcompresstest\libjpeg\jcapimin.c
文件 6042 2002-12-11 15:06 jpegcompresstest\libjpeg\jcapistd.c
文件 16849 2002-12-11 15:06 jpegcompresstest\libjpeg\jccoefct.c
............此处省略124个文件信息
- 上一篇:freeimage库的一个小
- 下一篇:国民经济行业分类.xlsx
相关资源
- VC显示图片(带滚动条完美控制)
- 捆绑文件异步同步操作vc源码
- MvCameraNode.xlsx
- vc OpenGL制作动态三维的雷达扫描效果
- VC 截获QQ聊天内容和登录密码.rar
- VC Agent动画小人仿OFFICE助手动画.ra
- VC 窗体美化源码_换肤改变窗口风格
- IDEA实现 springmvc的简单注册登录功能的
- SpringMVC+MyBatis企业应用实战+源码
- VC 6.0 补丁 FileTool.dll
- VC 实现的示波器控件 非常强大
- UVC图像获取及Extension unit数据获取
- 输入法注入源代码VC
- VCE 汉化补丁.txt
- VC Comment注释插件
- VC轻松实现非客户区按钮及源码
- STM32F103VCT6+W5500 TCP 服务端通信成功开
- OpenGL实现下雪的效果
-
VCPA-ba
sed hybrid strategy.zip - 车牌识别VC源代码
- VC 类似迅雷的悬浮窗
- SoCKit_RevC.pdf
- 机械革命ALC269VC带低音炮机型黑苹果仿
- 台达PLC通信程序VC
- VC-easyx绘图游戏简易教程
- 国密sm2算法c实现
- 传智播客 最新版淘淘商城视频教程及
- .NET MVC 中使用 kindeditor 中图片上传和
- vmware vsphere7.0全套
- VMware vsphere 6.7.0
评论
共有 条评论