Direct2D (9) : 显示图像
为什么80%的码农都做不了架构师?>>>
uses Direct2D;procedure TForm1.FormPaint(Sender: TObject);
varcvs: TDirect2DCanvas;wic: TWICImage;R: TRect;
beginwic := TWICImage.Create;wic.LoadFromFile('C:\Temp\Test.png');cvs := TDirect2DCanvas.Create(Canvas, ClientRect);cvs.BeginDraw;cvs.Draw(10, 10, wic);R := Bounds(wic.Width div 2 + 10, wic.Height div 2 + 10, wic.Width div 2, wic.Height div 2);cvs.StretchDraw(R, wic, 192);cvs.EndDraw;cvs.Free;wic.Free;
end;
效果图:
用较原始的办法重做上面的例子(通过 wic):
uses Direct2D, D2D1, Wincodec, ActiveX;{从指定文件建立 ID2D1Bitmap 对象的函数}
function GetD2D1Bitmap(RenderTarget: ID2D1RenderTarget; imgPath: string): ID2D1Bitmap;
variWicFactory: IWICImagingFactory;iWICDecoder: IWICBitmapDecoder;iWICFrameDecode: IWICBitmapFrameDecode;iFormatConverter: IWICFormatConverter;
begin{获取建立 WIC 的工厂}CoCreateInstance(CLSID_WICImagingFactory, nil, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, iWicFactory);{打开并获取解码后的对象}iWicFactory.CreateDecoderFromFilename(PWideChar(imgPath), GUID_NULL, GENERIC_READ, WICDecodeMetadataCacheOnLoad, iWICDecoder);{获取第一帧}iWicDecoder.GetFrame(0, iWICFrameDecode);{获取格式转换器}iWicFactory.CreateFormatConverter(iFormatConverter);{转换到与 D2D 兼容的格式}iFormatConverter.Initialize(iWICFrameDecode, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nil, 0, WICBitmapPaletteTypeMedianCut);{获取 ID2D1Bitmap}RenderTarget.CreateBitmapFromWicBitmap(iFormatConverter, nil, Result);
end;procedure TForm1.FormPaint(Sender: TObject);
varcvs: TDirect2DCanvas;iBitmap: ID2D1Bitmap;fRect: TD2DRectF;fSize: TD2DSizeF;
begincvs := TDirect2DCanvas.Create(Canvas, ClientRect);iBitmap := GetD2D1Bitmap(cvs.RenderTarget, 'C:\Temp\Test.png');iBitmap.GetSize(fSize);fRect := D2D1RectF(0, 0, fSize.width, fSize.height);cvs.BeginDraw;cvs.RenderTarget.SetTransform(TD2DMatrix3x2F.Translation(10, 10));cvs.RenderTarget.DrawBitmap(iBitmap, @fRect);fRect := D2D1RectF(0, 0, fSize.width/2, fSize.height/2);cvs.RenderTarget.SetTransform(TD2DMatrix3x2F.Translation(fRect.right+10, fRect.bottom+10));cvs.RenderTarget.DrawBitmap(iBitmap, @fRect, 0.75);cvs.EndDraw;cvs.Free;
end;
转载于:https://my.oschina.net/hermer/blog/320556
Direct2D (9) : 显示图像相关推荐
- 二、如何读入图片、显示图像?
一.如何读入.显示图像? 1.引入库 代码如下(示例): import cv2 img=cv2.imread(r'C:\Users\liewei\Desktop\pic\1.jpg',0)#0为灰度图 ...
- Direct2D (15) : 剪辑
为什么80%的码农都做不了架构师?>>> 绘制在 RenderTarget.PushAxisAlignedClip() 与 RenderTarget.PopAxisAligne ...
- Direct2D开发:Direct2D 和 GDI 互操作性概述
本主题说明如何结合使用 Direct2D 和 GDI(可能为英文网页).有两种方法可以结合使用 Direct2D 和 GDI:您可以将 GDI 内容写入与 Direct2D GDI 兼容的呈现器目标, ...
- Python显示图像
Python显示图像 import matplotlib.pyplot as plt # plt 用于显示图片 import matplotlib.image as mpimg # mpimg 用于读 ...
- 数组显示php,显示图像数组 - PHP
我有两个问题: - 问题编号:1(PHP相关) 我无法在PHP页面上显示图像数组.这里是我正在尝试的代码.. getUser.php $q=$_GET["q"]; $con = m ...
- Direct2D教程(三)简单几何图形
从本章开始,我们介绍D2D几何图形. D2D图形分类 Direct2D支持多种类型的几何图形,包括 Simple Geometry(简单几何图形) 矩形 圆角矩形 椭圆 Path Geometry(路 ...
- Direct2D (23) : 复合几何对象之 ID2D1GeometryGroup
为什么80%的码农都做不了架构师?>>> uses Direct2D, D2D1;procedure TForm1.FormPaint(Sender: TObject); va ...
- PIL图像处理:读取图像,显示图像,ROI,保存图像
PIL 读取图像,显示图像,ROI,保存图像 import matplotlib.pyplot as plt from PIL import Imagesrc_img = Image.open(Src ...
- Xamarin iOS教程之视图显示图像
Xamarin iOS教程之视图显示图像 Xamarin iOS显示图像 在主视图中显示一个图像,可以让开发者的应用程序变的更有趣,例如,在一些应用程序开始运行时,都会通过图像来显示此应用程序的玩法 ...
最新文章
- github中origin和upstream的区别(转)
- 怎样为wordpress主题的文章列表添加无插件分页?
- 浅谈自执行函数-立即调用的函数表达式
- Python3的编码问题
- java 排队实现_java中的优先列队-PriorityQueue源码实现解析
- HMM中的前向法(转)
- 电大有计算机教程吗,中央电大 计算机平面设计(上)
- XJTU_选课小助手
- 工业软件下载大全202108
- Micropython——看门狗定时器(WDT类)
- pyinstaller 打包exe启动慢的问题
- WIFI接口定义知识介绍
- windows中的DOS命令及变量
- 牛市回归,MATIC再创历史新高,马蹄ETF基金两周大涨152%
- Linux·信号量全解
- 文件服务器迁移方法,文件服务器迁移工具
- java面试题有哪些?
- linux网络命令--ping
- 制作apt-get本地源解决无网络情况下安装软件
- SWIM error [30006]: Comm init error: chip does not answer
热门文章
- 与 AI 博弈:从 AlphaGo 到 MuZero(三)
- FAST角点检测算法(二)- 非极大值抑制筛选fast特征点
- word2vec python实现
- 熔断机制什么意思_熔断机制是什么意思(图文)
- 怎么恢复苹果手机通讯录
- 重新编译CDH版本hadoop报错:Non-resolvable parent POM: Could not transfer artifact com.
- openCV教程01
- Spacy分词php,spaCy 第二篇:语言模型
- 基于HTML美中华传统文化题材网页项目的设计与实现 (纯HTML+CSS制作中国茶文化网站)...
- 相机的内参会改变吗_关于相机内参中的焦距fx和fy