急!
解决方案 »
- 拒了的offer还能再拿回来么?
- 当调试的时候 VS提示 “没有可用于当前位置的源代码”是怎么回事?
- 大虾米!OpenGL中画nurbs曲面的问题
- 关于编译中的fatal error C1070
- 如何编写一个基于对话框的启动画面,请高手详解!
- 带参数的存储过程问题,向各位高手求救!!!!!!!!!
- 请问如何得到并判断按下了“Shift+Delete”键?
- 用哪个API可以播放wavestream音频流?
- 我想作一个网络聊天程序 看了一些资料。但实际作是却发现问题多多 能不能给我一个简单的VC++原程序?
- 请问怎么得到比较详细的ASCII码表
- 做虚拟磁盘需要什么技术?
- 在VC中如何获得数据库存储过程里的输出参数
http://www.smalleranimals.com/jpegfile.htmImageHandler: A Component to Copy an HDC Area to a JPEG File
http://codeguru.earthweb.com/bitmap/ImageHandler.htmlWriting a DIB to a JPEG file
http://codeguru.earthweb.com/bitmap/dib_to_jpeg.shtmlCreating a DIB section from a BMP file
http://codeguru.earthweb.com/bitmap/dibsection_from_bmp.shtml
可以直接用的
可以实现转换
这又各小例子
http://www.vccode.com/file_show.php?id=2205
// 参数
// xs = 图象x轴大小
// ys = 图象y轴大小
// quality = jpeg图象质量
VOID SaveCurScreenJpg(LPCWSTR pszFileName, int xs, int ys, int quality)
{
HWND hwnd = ::GetDesktopWindow();
HDC hdc = GetWindowDC(NULL);
int x = GetDeviceCaps(hdc, HORZRES);
int y = GetDeviceCaps(hdc, VERTRES);
HBITMAP hbmp = ::CreateCompatibleBitmap(hdc, x, y), hold;
HDC hmemdc = ::CreateCompatibleDC(hdc);
hold = (HBITMAP)::SelectObject(hmemdc, hbmp);
BitBlt(hmemdc, 0, 0, x, y, hdc, 0, 0, SRCCOPY);
SelectObject(hmemdc, hold);
{
Bitmap bit(xs, ys), bit2(hbmp, NULL);
Graphics g(&bit);
g.ScaleTransform((float)xs/x, (float)ys/y);
g.DrawImage(&bit2, 0, 0);
CLSID encoderClsid;
EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
encoderParameters.Parameter[0].Value = &quality;
GetEncoderClsid(L"image/jpeg", &encoderClsid);
bit.Save(pszFileName, &encoderClsid, &encoderParameters);
}
::DeleteObject(hbmp);
::DeleteObject(hmemdc);
return;
}