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;

  • 相关阅读:
    C语言(十八)综合
    C语言(十七)链表
    Redis使用
    fastdb 使用
    CentOS 7.3 安装Oracle 11gR2 64位
    VMWare 12 安装CentOS 7.3 和 Red Hat Enterprise Linux 7.3
    Python学习
    Debian的软件包管理工具命令 (dpkg,apt-get)详解
    Debian8安装Vim8
    VMware12下安装Debian8.5
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2035823.html
Copyright © 2011-2022 走看看