FMX解析BMP文件工厂
unit FMX.Canvas.D2D;
initialization
TTextLayoutManager.RegisterTextLayout(TTextLayoutD2D, TCanvasD2D);
TBitmapCodecManager.RegisterBitmapCodecClass(SBMPImageExtension, SVBitmaps, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SJPGImageExtension, SVJPGImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SJPEGImageExtension, SVJPGImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SPNGImageExtension, SVPNGImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SGIFImageExtension, SVGIFImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(STIFImageExtension, SVTIFFImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(STIFFImageExtension, SVTIFFImages, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SICOImageExtension, SVIcons, True, TBitmapCodecWIC);
TBitmapCodecManager.RegisterBitmapCodecClass(SHDPImageExtension, SWMPImages, True, TBitmapCodecWIC);
end.
class procedure TBitmapCodecManager.RegisterBitmapCodecClass(const Extension, Description: string; const CanSave: Boolean;
const BitmapCodecClass: TCustomBitmapCodecClass);
var
LDescriptor: TBitmapCodecClassDescriptor;
begin
if FBitmapCodecClassDescriptors = nil then
FBitmapCodecClassDescriptors := TList<TBitmapCodecClassDescriptor>.Create;
LDescriptor.Extension := Extension;
LDescriptor.Description := Description;
LDescriptor.BitmapCodecClass := BitmapCodecClass;
LDescriptor.CanSave := CanSave;
FBitmapCodecClassDescriptors.Add(LDescriptor);
end;
class function TBitmapCodecManager.LoadFromFile(const AFileName: string; const Bitmap: TBitmapSurface;
const MaxSizeLimit: Cardinal = 0): Boolean;
var
CodecClass: TCustomBitmapCodecClass;
Codec: TCustomBitmapCodec;
begin
CodecClass := FindBitmapCodecDescriptor(ExtractFileExt(AFileName),
TBitmapCodecDescriptorField.Extension).BitmapCodecClass;
if CodecClass <> nil then
begin
Codec := CodecClass.Create;
try
Result := Codec.LoadFromFile(AFileName, Bitmap, MaxSizeLimit);
finally
Codec.Free;
end;
end
else
Result := False;
end;
procedure TBitmap.LoadFromFile(const AFileName: string);
var
Surf: TBitmapSurface;
begin
Surf := TBitmapSurface.Create;
try
if TBitmapCodecManager.LoadFromFile(AFileName, Surf, CanvasClass.GetAttribute(TCanvasAttribute.MaxBitmapSize)) then
Assign(Surf)
else
raise EBitmapLoadingFailed.CreateFMT(SBitmapLoadingFailedNamed, [AFileName]);
finally
Surf.Free;
end;
end;
最新文章
- 理解Docker(3):Docker 使用 Linux namespace 隔离容器的运行环境
- mybatis-config.xml简单笔记
- 关于 MAXScript 中文路径返回上级目录(精简版)
- Linux常用压缩和解压命令
- 【kAri OJ620】winoros的树
- linux设备驱动归纳总结(六):3.中断的上半部和下半部——tasklet【转】
- SqlServer存储过程
- Javascript与Ajax
- 线段树(单点更新)HDU1166、HDU1742
- redis常见错误
- PAT 1002 Hello World for U (20)
- android application简要类(一)
- layoutSubview触发时机
- JDK、JRE、JVM详解
- 为什么在Python里推荐使用多进程而不是多线程
- Android监听自身卸载,弹出用户反馈调查
- 深入学习MySQL事务:ACID特性的实现原理
- ElasticSearch 6.2 Mapping参数说明及text类型字段聚合查询配置
- 翻译:赋值操作符(:=)(已提交到MariaDB官方手册)
- springcloud-4:服务注册(hello-service)
热门文章
- CentOS7.5下时间戳转换为时间
- 安装Caffe时出现的错误
- controller中,Failed to Initialize. Reason: TimeOut虚拟用花初始化超时
- JavaScript之setInterval() 函数
- JS获取select的value和text值的简单实例
- Python添加系统路径BASE_DIR
- javascript入门教程笔记
- Ubuntu16.04安装mongodb 及使用
- python解决组合问题
- functools.wraps 带参数的装饰器 多个装饰器装饰同一个函数