问题如下:
有三个图片控件,image1,image2,image3,image4 大小为image1(200,200),image2(200,200),image3(1000,1000),image4(5,5) 我想把image1与image2的图片,结何实现透明,并且把每一点放大5倍,放到image3上.我的思路是: 对image1,image2每一点读出来,并且扩大该点为5倍大小,即为(5,5)加以混合运算实现半稳明,然后把该点(5*5)大小的图片拷贝到image3上,请问我的思路是否正确呢?
我用上面这种思路编写了一段程序,程序结构如下:
for x:=0 to 199 do begin
for y:=0 t0 199 do begin
(1) 我根据y的值为透明值,
(2) 现在我(x,y)点读出,使image4的色素为(x,y)点的色素,而且要使image4为透明.透明值为 y ,
{ 上面我为了实现 image4 透明,又加了两个for循环
for xx:=0 to 4 do begin
for yy:=0 to 4 begin
end;
end;
}
(3) 现在就把image4的图片拷贝到image3上去.
end;
end;
小弟把整个程序写完,但加载速度有点慢.所以来请教高手,实现上面的功能思路上有没有更好的解决方法呢? 高手们可以说一说你们更好的想法呢? 从算法上能否在修改修改呢?
有三个图片控件,image1,image2,image3,image4 大小为image1(200,200),image2(200,200),image3(1000,1000),image4(5,5) 我想把image1与image2的图片,结何实现透明,并且把每一点放大5倍,放到image3上.我的思路是: 对image1,image2每一点读出来,并且扩大该点为5倍大小,即为(5,5)加以混合运算实现半稳明,然后把该点(5*5)大小的图片拷贝到image3上,请问我的思路是否正确呢?
我用上面这种思路编写了一段程序,程序结构如下:
for x:=0 to 199 do begin
for y:=0 t0 199 do begin
(1) 我根据y的值为透明值,
(2) 现在我(x,y)点读出,使image4的色素为(x,y)点的色素,而且要使image4为透明.透明值为 y ,
{ 上面我为了实现 image4 透明,又加了两个for循环
for xx:=0 to 4 do begin
for yy:=0 to 4 begin
end;
end;
}
(3) 现在就把image4的图片拷贝到image3上去.
end;
end;
小弟把整个程序写完,但加载速度有点慢.所以来请教高手,实现上面的功能思路上有没有更好的解决方法呢? 高手们可以说一说你们更好的想法呢? 从算法上能否在修改修改呢?
解决方案 »
- 请教一个关于DBNavigator的小问题!!!
- 请问除了CppWebBrowser还有什么控件可以显示网页吗?
- DAT媒体播放的问题!
- 如何实现TcxGridDBTableView的Cell之间的数据拖动
- 如何应用dxExpress的SimpleDataSet读取其导出的XML文件。
- 应用程序在98上,怎么连接不上2000上的SQLS2000,急!
- 如何获得数据库结构的信息
- 向高手求助
- 如何改变trichedit中某个字符串的颜色?
- to 7415004(7415004):'在一个贴子里你回复不能超过30次!!'看这里
- 新手问一个关于DBNavigator的问题,,
- 如何控制DBGrid上數據的變化
估计是很慢吧
-------------
给你个高手写的图形模糊,主要是用指针,速度比较快
你研究一下,就能加快速度了
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;type
TRGB=record
Red,Green,blue:byte;
end;
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Button1: TButton;
Splitter1: TSplitter;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Soften( Sou,Des: Tbitmap);
end;var
Form1: TForm1;implementationuses Types;{$R *.dfm}{ TForm1 }procedure TForm1.Soften( Sou,Des: Tbitmap);
type
TColor32 = packed record
R,G,B,A : Byte ;
end ;
Pcolor32 = ^TColor32 ;
TColor32s = array[0..1000] of TColor32 ;
PColor32s = ^TColor32s ;
var
i,j,n:integer;
red,green,blue:integer;
Pls :array[0..2] of PColor32s ;
dpl :PColor32s ;
p1,p2,p0 :pointer ;
begin
for i :=0 to Sou.Height-1 do
begin
dpl := Des.ScanLine[i] ;
pls[1] := sou.ScanLine[i] ;
if not ((i<1)or(i>Sou.Height-2)) then
begin
pls[0] := sou.ScanLine[i-1] ;
pls[2] := sou.ScanLine[i+1] ;
end;
for j :=0 to Sou.Width-1 do
begin
dpl^[j] := pls[1]^[j] ;
if (i <2)or(i>(Sou.Height-2)) then Continue ;
if (j <2)or(j>(Sou.Width-2)) then Continue ;
red :=0;
blue :=0 ;
green :=0 ;
for n := 0 to 2 do
begin
p0:=@(pls[0]^[j-1+n]);
p1:=@(pls[1]^[j-1+n]);
p2:=@(pls[2]^[j-1+n]);
red := red+PColor32(p0).R+PColor32(p1).R+PColor32(p2).R ;
blue :=blue+ PColor32(p0).B+PColor32(p1).B+PColor32(p2).B ;
Green :=green+ PColor32(p0).G+PColor32(p1).G+PColor32(p2).G ;
end;
{$R-}
PColor32(@(dpl^[j]))^.r := red div 9 ;
PColor32(@(dpl^[j]))^.g := green div 9 ;
PColor32(@(dpl^[j]))^.b := blue div 9 ;
{$R+}
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
SorBitmap,DesBitmap:TBitmap;
begin
(Sender as TButton).Enabled:=not (Sender as TButton).Enabled;
SorBitmap:=TBitmap.Create;
SorBitmap.LoadFromFile('F:\1.bmp');
SorBitmap.PixelFormat := pf32bit ;
Image1.Picture.Bitmap.Assign(SorBitmap); DesBitmap:=TBitmap.Create;
DesBitmap.Assign(SorBitmap);
DesBitmap.PixelFormat := pf32bit ; //Soften(SorBitmap,DesBitmap); //SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap);
{SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap); SorBitmap.Assign(DesBitmap);
Soften(SorBitmap,DesBitmap);} DesBitmap.SaveToFile('F:\2.bmp');
Image2.Picture.Bitmap.Assign(DesBitmap);
SorBitmap.Free;
DesBitmap.Free;
(Sender as TButton).Enabled:=not (Sender as TButton).Enabled;
end;
end.