-
Delphi 制作红绿眼镜三维立体画
这是一个Delphi色彩控制方面的示例,我看上去更像是Delphi分离出红绿颜色通道,从页形成的一种立体效果,复制和修改颜色模式来实现,相关代码可参考如下:
//设置添充颜色的大小
DBitmap.Width := LBitmap.Width;
DBitmap.Height := LBitmap.Height;
vRect := Rect(0, 0, DBitmap.Width, DBitmap.Height); //获取添充区域
DBitmap.Canvas.Brush.Color := vGreen; //设置画笔颜色
DBitmap.Canvas.FillRect(vRect); //添充颜色
LBitmap.Canvas.CopyMode := cmSrcPaint; //将复制模式改为OR
LBitmap.Canvas.CopyRect(vRect, DBitmap.Canvas, vRect); //对图片进行复制
DBitmap.Canvas.Brush.Color := vRed;
DBitmap.Canvas.FillRect(vRect);
RBitmap.Canvas.CopyMode := cmSrcPaint; //将复制模式改为OR
RBitmap.Canvas.CopyRect(vRect, DBitmap.Canvas, vRect); //对图片进行复制
DBitmap.Canvas.CopyRect(vRect, LBitmap.Canvas, vRect);
DBitmap.Canvas.CopyMode := cmSrcAnd; //将复制模式改为AND
DBitmap.Canvas.CopyRect(vRect, RBitmap.Canvas, vRect);
except
Exit;
end;
Result := True;
end;
- 2023-02-01 08:05:04下载
- 积分:1
-
Delphi 实现图像热点功能
Delphi 实现图像热点功能,实现一张图片上不同形状区域的热点,定义椭圆形、四边形、三角形的区域变量的热点,相关代码如下:
var
thepoint:array [1..8] of tpoint;//存储多边形顶点坐标
count:integer;
pointnum:array [1..2] of integer;
begin
//四边形顶点坐标,首末点封闭
thepoint[1]:=point(135,99);
thepoint[2]:=point(105,183);
thepoint[3]:=point(129,201);
thepoint[4]:=point(188,92);
thepoint[5]:=point(135,99);
count:=5;//四边形顶点数目,首末点为一点
fourE_rgn:=CreatePolygonRgn(thepoint,count,WINDING);//生成四边形区域
elli_rgn:=CreateEllipticRgn(64,221,231,263);// 生成椭圆形区域
//第一个三角形顶点坐标
thepoint[1]:=point(118,67);
thepoint[2]:=point(32,28);
thepoint[3]:=point(17,90);
thepoint[4]:=point(118,67);
//第二个三角形顶点坐标
thepoint[5]:=point(155,44);
thepoint[6]:=point(202,91);
thepoint[7]:=point(277,44);
thepoint[8]:=point(155,44);
pointnum[1]:=4;//第一个三角形顶点数目
pointnum[2]:=4;//第二个三角形顶点数目
count:=2;//三角形数目
//生成由两个三角形构成的三角形区域
tri_rgn:=CreatePolyPolygonRgn(thepoint,pointnum,count,WINDING);
end;
- 2022-01-26 08:02:50下载
- 积分:1
-
Delphi 渐变的RGB空心色环绘制源码演示
Delphi渐变圆形的实现方法,RGB色环空心绘制演示源码:
oBmp := TBitmap.Create; //为了代码整齐就不写try了
oBmp.PixelFormat := ABitmap.PixelFormat;
oBmp.Width := ABitmap.Width;
oBmp.Height := ABitmap.Height;
BitBlt(oBmp.Canvas.Handle, 0, 0, oBmp.Width, oBmp.Height, ABitmap.Canvas.Handle, 80, 80, SRCCOPY); //要拷贝的位图
oRgn := CreateEllipticRgn(0, 0, 100, 100); //创建圆形区域
SelectClipRgn(ABitmap.Canvas.Handle, oRgn); //选择剪切区域
ABitmap.Canvas.Draw(0, 0, oBmp); //位图位于区域内的部分加载
- 2022-03-21 13:09:53下载
- 积分:1
-
Delphi在窗口中单击左键弹出菜单
Delphi在窗口中单击左键弹出菜单,在运行的窗体空白外,单击鼠标左键,弹出主菜单,其实和右键 菜单 是一样的原理,希望通过这个简单的例子,了解自定义窗口菜单的实现方法。
- 2023-09-08 18:20:03下载
- 积分:1
-
Delphi为程序添加esc退出程序的功能
本源码演示Delphi如何用ESC键退出程序,为程序添加esc退出程序的功能,一般情况下,关闭程序都是通过ALT+f4或者直接点击窗口右上角的叉子关闭,不过我们也可以为程序添加通过键盘按下ESC键来关闭程序,本源码就是演示了此种功能,当用户按下ESC时,窗口即关闭,程序退出。
- 2022-07-21 22:03:47下载
- 积分:1
-
形象的电子表-Delphi程序
Delphi编写制作一款形象的电子表(钟表)效果,模拟时钟,界面方面做成了圆形,看不见窗口的边框,像是透明的窗口,各个指针会走动,关于各个指针的移动及计算方法,有兴趣可参考:
vh := Hour/12.0*2*Pi;
vm := Min/60.0*2*Pi;
vs := Sec/60.0*2*Pi;
with Canvas do
begin
Pen.Width:=4;
Pen.Color := clBlack;
MoveTo(60,60);
LineTo(60+Round(25*Sin(vh)),60-Round(25*Cos(vh)));
Pen.Width:=2;
Pen.Color := clBlack;
MoveTo(60,60);
LineTo(60+Round(45*Sin(vm)),60-Round(45*Cos(vm)));
Pen.Width:=1;
Pen.Color := clRed;
MoveTo(60,60);
LineTo(60+Round(55*Sin(vs)),60-Round(55*Cos(vs)));
end;
窗体方面:这个圆盘窗口要是能移动就好了,不支持右键菜单,也不能关闭,关闭窗口需要按键盘上的ALT+F4。
- 2022-01-27 12:29:32下载
- 积分:1
-
在Delphi中进行 YCrCb RGB 颜色值转换
在Delphi中进行 YCrCb RGB 颜色值转换,载入一张测试图片,右侧显示的转换后的颜色图像,文本框中显示的是各个转换过的颜色值。希望通过这个Delphi例子,帮你了解一下YCrCb向RGB颜色值的转换过程,转换方法和思路,本源码中则是具体的实战代码,请下载后研究。
- 2022-05-23 08:16:07下载
- 积分:1
-
使用Delphi 制作无闪烁的动画效果
使用Delphi 制作无闪烁的动画效果,如何实现不闪烁的动画呢?这个例子或许能找到一些答案:部分代码如下:
var
x,i: Integer;
dir,run: Boolean;
begin
b := TBitMap.Create;
b.Width := AnimWindow.Width;
b.Height := 32;
b.Canvas.Pen.Color := clBtnFace;
b.Canvas.Brush.Color := clBtnFace;
b.Canvas.Rectangle(0,0,AnimWindow.Width,32);
run := True;
dir := False;
x := 0;
while run do
for i := 0 to AnimWindow.ImageList1.Count-1 do
begin
b.Canvas.Rectangle(0,0,AnimWindow.Width,32);
AnimWindow.ImageList1.Draw(b.Canvas,x,0,i);
Synchronize(DrawAnimPic);
Sleep(AnimWindow.SpinEdit1.Value);
if (x = 0) or (x = 300) then dir := not dir;
if dir then Inc(x) else Dec(x);
end;
b.Free;
end;
- 2023-03-22 21:40:04下载
- 积分:1
-
Delphi 将TDBGrid导入到Excel表中附数据库
Delphi7.0将TDBGrid导入到Excel表中,测试程序先连接好SQLSERVER数据库,并将数据读取到TDBGrid中,然后再将数据从TDBGrid导入到Excel表中,为了测试方便,SQLSERVER数据库文件已经附在源码包中。以下代码片断会有参考意义,完整源码请下载:
//将TDBGrid表中的标题插入到Excel表中的首行
for I:=0 to DbName.Columns.Count-1 do
begin
if DbName.Columns[i].Visible=False then
Continue;
Page.Cells[j,i+1] := DbName.Columns[i].Title.Caption;
Page.Cells[j,i+1].Font.Bold := True; //设置字体为粗体
end;
Inc(j); //Excel表中的下一行
First; //将指针返回到TDBGrid表中数据的首行
while not Eof do
begin
for i:=0 to DbName.Columns.Count-1 do
begin
if DbName.Columns[i].Visible=False then
Continue;
//将指定行中每列的数据,添加到Excel表中
Page.Cells[j,i+1] := trim(DbName.DataSource.DataSet.Fieldbyname(DbName.Columns[i].FieldName).asstring);
end;
Inc(j); //Excel表中的下一行
Next; //TDBGrid表中的下一条记录
end;
- 2022-06-29 23:05:07下载
- 积分:1
-
Delphi 获取服务器时间 更新本机时间
Delphi 通过时间服务器更新时间,包括了两个功能:1、获取服务器时间,2、更新本机时间。通过时间服务器,可一键自动更新日期时间,不过本实例连接的服务器已经失效了,程序不能连接,会假死,测试时候要注意。
- 2022-01-24 08:49:50下载
- 积分:1