首页 > 其他分享 >delphi 资源文件管理 Resources and Images

delphi 资源文件管理 Resources and Images

时间:2023-04-08 12:24:40浏览次数:34  
标签:stream delphi Resources Images TPNGObject Create png TResourceStream

1、  把PNG图片放到项目中;

2、  点击主菜单“Project”→“ Resources and Images”,弹出下面的对话框

  它会自动识别项目中的图片、音频等文件自动添加进来,如果没有识别出来或者是自定义文件类型的话,就点击【Add】按钮手动添加,然后选择合适的资源类型ResourceType,然后在Resource Identifier中给资源取一个名字即可。

在代码中使用TResourceStream读取资源流:

stream := TResourceStream.Create(HInstance, 'PNGIMAGE_PAUSE',  RT_RCDATA);
DelphiXE中已经提供了Png解析库,uses pngimage,然后:
png := TPNGObject.Create;
png.LoadFromStream(stream);

下面是我封装的一个简单的从资源中读取PNG对象的方法:
function LoadPNGResource(resName:string):TPNGObject;
var
  png: TPNGObject;
  stream: TResourceStream;
begin
  png := TPNGObject.Create;
  stream := TResourceStream.Create(HInstance, 'PNGIMAGE_PAUSE',  RT_RCDATA);
  try
    png.LoadFromStream(stream);
  finally
    stream.Free;
  end;
  result := png;
end;

 

标签:stream,delphi,Resources,Images,TPNGObject,Create,png,TResourceStream
From: https://www.cnblogs.com/sixty-five/p/17298301.html

相关文章

  • Delphi WebBrowser调用WebSocket 服务
    webSocketDemo使用工具:WebBrowser传输参数:delphi给js赋值JSON字符串,js接收到后通过JSON.parse()方法转换成JSON对象,然后根据需要参数进行读取,Delphi通过SuperObject处理JSON数据调用JSON方法:WebBrowser1.oleObject.document.parentWindow.execScript('js方法名'......
  • ImageSwitcher&Gallery练习
    先看图再说:布局如下:<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout......
  • delphi FastReport 常用功能
    FastReport常用功能属性和方法TfrxReport.LoadFromFilefunctionLoadFromFile(constFileName:String;ExceptionIfNotFound:Boolean=False):Boolean;从给定名称的文件中加载报表。如果文件加载成功,返回True。参数FileName文件的名称。ExceptionIfNotFound如果为T......
  • Delphi-UniCode转汉字(\u 格式)、汉字转UniCode(\u 格式)
     相关资料:https://www.cnblogs.com/guorongtao/p/14729102.html     DelphiUniCode转汉字(\u格式)、汉字转UniCode(\u格式)实例代码:1、UniCode转汉字functionUnicodeToChinese(sStr:string):string;vari:Integer;index:Integer;temp,top,last:s......
  • assembly.GetManifestResourceStream嵌入资源
    varassembly=Assembly.GetExecutingAssembly();varstream=assembly.GetManifestResourceStream(path)得到的stream是null,解决办法:找到文件,右键-属性-......
  • 设备树的概念(三) :处理资源(Handling resources)
    驱动程序的主要目的是处理和管理设备,大多数时候将它们的功能暴露给用户空间。这里的目标是收集设备的配置参数,特别是资源(内存区域、中断线、DMA通道、时钟等)。下面是我......
  • delphi TMS FlexCel 设置页面布局(打印、导出调整为合适大小)
    TMSFlexCel设置页面布局(打印、导出调整为合适大小)属性和方法TXlsFile.PrintScalepropertyTXlsFile.PrintScale:Integer页面布局中的缩放比例,扩大/缩小工作表的百......
  • php 截图(可预览) crop images thumb jcrop/asido
    jcrop+asido  index.php  <?php$targ_w=90;//thumbwidthsize$targ_h=89;//thumbheightsize$filename=$_GET['file'];if($filename){$abs=......
  • Delphi泛型学习(一)TList<Interger>
    varList:TList;FoundIndex:Integer;begin{CreateanewList.}List:=TList.Create;{Addafewvaluestothelist.}List.AddRange([5,1,8,2,9,14,4,......
  • Delphi Locate函数[1] - 查询、定位
     DelphiTDataSet.Locate函数-查询、定位使用ADO等数据控件的时候,经常会用到 locate函数,在结果数据集中查询和定位,下面介绍一下:原型:1function Locat......