资源简介
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
相关资源
- Windows异步套接字网络编程
- VC 获得文件属性 获取文件的创建时
- 基于MVC模式的会员管理系统
- silicon lab公司的收音IC SI47XX全套开发工
- 读者写者问题(读者优先,写者优先
- MFC程序-碰撞的小球
- vc 柱形图 CBarChart
- 用vc 写的导线测量,针对刚学测绘的
- 用VC 编写的仿QQ聊天室程序源代码
- 栅栏填充算法源码(VC)
- 简单的房屋租赁系统
- .net网站服装销售系统(MVC)
-
ob
jectARX给Auto CAD加工具条 - blowfish的vc2008工程.rar
- 画图程序MFC/VC/VC CRectTracker 串行化
- capon波束形成算法-VC实现
- 读取串口数据并画实时曲线的VC 程序
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
- keil vcom windows 7 64bit 驱动
- vc URL编解码类
- vc编写中国象棋详细源码注释并附有视
- VC 围棋源代码
- 用VC 编写的基于SNMP的路由器拓扑程序
- vc利用MFC底层开发的二维GIS管理软件,
- 兰勃托地图投影VC源码
- 清华大学郑莉C 语言程序设计课件
评论
共有 条评论