zoukankan      html  css  js  c++  java
  • 高斯模糊

    procedure Effect_GaussianBlur(Amount:integer;Picture:TBitmap);

    var BB:TBitmap;

    begin

    BB :=TBitmap.Create;

    BB.PixelFormat :=pf24bit;

    BB.Assign(Picture.Bitmap);

    GaussianBlur(BB,Amount);

    Picture.Bitmap.Assign(BB);

    BB.Free;

    end;

    procedure GaussianBlur(var clip:TBitmap;Amount:integer);

    var

    i:integer;

    begin

    for i:=Amount downto 0 do

    SplitBlur(clip,3);

    end;

    procedure SplitBlur(var clip:TBitmap;Amount:integer);

    var

    p0,p1,p2:PByteArray;

    cx,x,y:integer;

    Buf:array[0..3,0..2] of byte;

    begin

    if Amount=0 then Exit;

    for y:=0 to clip.Height-1 do

    begin

    if y-Amount<0 then

    p1:=clip.Scanline[y]

    else

    p1:=clip.Scanline[y-Amount];

    if y+Amount<clip.Height then

    p2:=clip.Scanline[y+Amount]

    else

    p2:=clip.Scanline[clip.Height-y]

    for x:=0 to clip.Width-1 do

    begin

    if x-Amount<0 then cx:=x;

    Buf[0,0]:=p1[cx*3];

    Buf[0,1]:=p1[cx*3+1];

    Buf[0,2]:=p1[cx*3+2];

    Buf[1,0]:=p2[cx*3];

    Buf[1,1]:=p2[cx*3+1];

    Buf[1,2]:=p2[cx*3+2];

    if x+Amount<clip.Width then

    cx:=x+Amount

    else

    cx:=clip.Width-x;

    Buf[2,0]:=p1[cx*3];

    Buf[2,1]:=p1[cx*3+1];

    Buf[2,2]:=p1[cx*3+2];

    Buf[3,0]:=p1[cx*3];

    Buf[3,1]:=p1[cx*3+1];

    Buf[3,2]:=p1[cx*3+2];

    p0[x*3+1]:=(Buf[0,1]+Buf[1,1]+Buf[2,1]+Buf[3,1]) shr 2;

    p0[x*3+2]:=(Buf[0,2]+Buf[1,2]+Buf[2,2]+Buf[3,2]) shr 2;

    end;

    end;

    end;

  • 相关阅读:
    Shell编程------函数应用
    Shell编程------循环语句
    Shell编程------判断语句
    Shell编程------变量、赋值和运算
    Action实现prepareable接口后定义前置方法
    动态代理模式
    hibernate持久化对象,
    view视图总结
    servlet和Struts2的线程安全性对比
    Action获取请求参数的3中方式
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2035823.html
Copyright © 2011-2022 走看看