请助无窗体dll怎么处理图片Timage

asktaor 2015-07-14 04:26:12
请助无窗体dll怎么处理图片


我查了Timgage需要 建立在Tform上
但是 我的dll需要 把数据保存为图片
可是我又没有窗体不能够用 image1.savetojpeg('C:\文件.jpg');


请问怎么处理。谢谢、

一调用就出错



unit TestFun;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, dateutils, ExtCtrls;
var
img1: TImage;
procedure Test; stdcall
implementation

procedure Test; stdcall
var i: integer;
begin
img1.Width := 200;
img1.Height := 200;
img1.Picture.Graphic := nil; // 消除原有的图形 或者 image.picture:=nil;都可以
img1.Canvas.Pen.Style := TPenStyle(0); // 设置画笔类型
img1.Canvas.MoveTo(0, 0); // 将当前画笔位置移到(0,0)

img1.Canvas.Font.Color := clBlack;
img1.Canvas.Font.Name := '宋体';
// img1.Canvas.Font.Style := [fsBold, fsItalic, fsUnderline, fsStrikeOut];
img1.Canvas.Font.Size := 11;

for i := 0 to 5 do
img1.Canvas.TextOut(0, i * 18, inttostr(i));

img1.savetofile('C:\己阅.jpg');

end;

end.


...全文
118 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
asktaor 2015-07-14
  • 打赏
  • 举报
回复
引用 1 楼 wallace_xie 的回复:
img1都没有create; procedure Test; stdcall var i: integer; begin img1: =TImage.create(nil); img1.Width := 200; img1.Height := 200; img1.Picture.Graphic := nil; // 消除原有的图形 或者 image.picture:=nil;都可以 img1.Canvas.Pen.Style := TPenStyle(0); // 设置画笔类型 img1.Canvas.MoveTo(0, 0); // 将当前画笔位置移到(0,0) img1.Canvas.Font.Color := clBlack; img1.Canvas.Font.Name := '宋体'; // img1.Canvas.Font.Style := [fsBold, fsItalic, fsUnderline, fsStrikeOut]; img1.Canvas.Font.Size := 11; for i := 0 to 5 do img1.Canvas.TextOut(0, i * 18, inttostr(i)); img1.savetofile('C:\己阅.jpg'); img1.free; end;
感谢您的回复。完美解决了。没有保错 我之前一直写成了 img1.create(nil) 一直出错 原来是要 img1:=Timage.create(nil); 看来基础还是不好。万分感谢您的帮忙
缘中人 2015-07-14
  • 打赏
  • 举报
回复
厉害
wallace_xie 2015-07-14
  • 打赏
  • 举报
回复
img1都没有create; procedure Test; stdcall var i: integer; begin img1: =TImage.create(nil); img1.Width := 200; img1.Height := 200; img1.Picture.Graphic := nil; // 消除原有的图形 或者 image.picture:=nil;都可以 img1.Canvas.Pen.Style := TPenStyle(0); // 设置画笔类型 img1.Canvas.MoveTo(0, 0); // 将当前画笔位置移到(0,0) img1.Canvas.Font.Color := clBlack; img1.Canvas.Font.Name := '宋体'; // img1.Canvas.Font.Style := [fsBold, fsItalic, fsUnderline, fsStrikeOut]; img1.Canvas.Font.Size := 11; for i := 0 to 5 do img1.Canvas.TextOut(0, i * 18, inttostr(i)); img1.savetofile('C:\己阅.jpg'); img1.free; end;

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧