draw JPEG (windows)[ing..]
[20110122_2324] 发现资料看到一定程度就不记随笔了,,因为开始大量查找内容,,觉得很点睛的内容已经没了.
[20110123_2315] CopyPalette,并非所有 图像帧 都有调色板. 4位图有, 16, 32位图没有.
[20110123_2315] GetPixelFormat,能获得图像格式. 但是GUID编码, 非int,string等格式, 无法直接使用.
GetSize, 能获得图像width, length.
Solution
WIC sample http://msdn.microsoft.com/en-us/library/ee720055(v=VS.85).aspx
JPEG Overview http://msdn.microsoft.com/en-us/library/gg430026(vs.85).aspx#_imagequality
Decoding Overview http://msdn.microsoft.com/en-us/library/ee719870(v=vs.85).aspx
Bitmap Sources Overview http://msdn.microsoft.com/en-us/library/ee719656(v=vs.85).aspx#_bitmapsources
找到好链接, 很快就能学会应用了.
WIC Sample是最后找到的.但问题是解决最直接的, 直接实例, 再结合前面的Define学快很多.
Key Function
IWICBitmapScaler 拉伸图像
IWICFormatConverter 转换图像调色板颜色, 通道颜色.
QueryInterface 对象转存
pConverter->QueryInterface(IID_PPV_ARGS(ppToRenderBitmapSource));
Graphics Class [GDI+]
结果: 图片质量低
http://msdn.microsoft.com/en-us/library/ms534453(v=VS.85).aspx
// 代码只是示意流程, 不能直接使用.
#include <windows.h>
#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
INT main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Image* image = new Image(L"D:\\Project\\c++\\lee_win32_2\\JPEG.jpg");
Graphics graphics(hdc);
graphics.DrawImage(image, 10, 10);
graphics.DrawImage(image, 0.0f, 0.0f, 0.0f, 0.0f, 300.0f, 1000.0f, UnitPixel);
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
ing..
在找如何提升Graphics解压JPEG质量的参数, 以上流程显示的图片, 实在非常不清楚.
GSetDIBitsToDevice, StretchDIB [GDI]
正在跟踪, 还没解决.
http://msdn.microsoft.com/en-us/library/dd145131(v=vs.85).aspx
//
// pvJpgImage points to a buffer containing the JPEG image
// nJpgImageSize is the size of the buffer
// ulJpgWidth is the width of the JPEG image
// ulJpgHeight is the height of the JPEG image
//
//
// Check if CHECKJPEGFORMAT is supported (device has JPEG support)
// and use it to verify that device can handle the JPEG image.
//
ul = CHECKJPEGFORMAT;
if (
// Check if CHECKJPEGFORMAT exists:
(ExtEscape(hdc, QUERYESCSUPPORT,
sizeof(ul), &ul, 0, 0) > 0) &&
// Check if CHECKJPEGFORMAT executed without error:
(ExtEscape(hdc, CHECKJPEGFORMAT,
pvJpgImage, nJpgImageSize, sizeof(ul), &ul) > 0) &&
// Check status code returned by CHECKJPEGFORMAT:
(ul == 1)
)
{
//
// Initialize the BITMAPINFO.
//
memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = ulJpgWidth;
bmi.bmiHeader.biHeight = -ulJpgHeight; // top-down image
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 0;
bmi.bmiHeader.biCompression = BI_JPEG;
bmi.bmiHeader.biSizeImage = nJpgImageSize;
//
// Do the SetDIBitsToDevice.
//
iRet = SetDIBitsToDevice(hdc,
ulDstX, ulDstY,
ulDstWidth, ulDstHeight,
0, 0,
0, ulJpgHeight,
pvJpgImage,
&bmi,
DIB_RGB_COLORS);
if (iRet == GDI_ERROR)
return FALSE;
}
else
{
//
// Decompress image into a DIB and call SetDIBitsToDevice
// with the DIB instead.
//
}
ing..
[20110117_1100] : 由此证实可以用GDI打印, 问题是有4个参数还没搞清楚怎么获得.
[20110117_1222] : JPEG从文件读入后, 需要先解码, 再使用.
The Windows Imaging Component (WIC) is an extensible platform that provides low-level API for digital images.
Introduction
Native Bitmap Decoders
IWICBitmapDecoder interface 本地图片解压 : 支持网络图片, 高清动态图片,BMP,GIF,ICO,JPEG,PNG,TIFF,HD photo.
global level: 可能不支持缩略图等属性
frame level: 但frame level支持
| Method | Description |
|---|---|
| CopyPalette |
调色板 |
| GetColorContexts |
颜色关系 |
| GetContainerFormat |
容器格式(GUID) |
| GetDecoderInfo |
WICBitmapDecoderInfo |
| GetFrame |
某一帧 |
| GetFrameCount |
总帧数 |
| GetMetadataQueryReader |
|
| GetPreview |
预览 |
| GetThumbnail |
缩略图 |
| Initialize |
|
| QueryCapability |
ImageQuality Option
BitmapTransform Option
Bitmap Sources
IWIBitmapSource接口是很多WIC接口的基础, 例如IWICBbitmapFrameDecode, IWIBitmapFlipRotator.
CopyPixels Method
拷贝图像是 图形解压2个重要过程中的1个.
它通过算法, 解压JPEG图片, 图片可能在disk,memory中, 甚至解压一个复杂的渐变.
算法完全依赖于CopyPixels接口的实现.
IWICBitmap Interface
浙公网安备 33010602011771号