Drawning bitmap & copying it to other canvas

Please discuss general Delphi programming topics here.

Drawning bitmap & copying it to other canvas

Postby Johnny_Bit » August 4th, 2003, 11:06 am

I want to draw bitmap to specified canvas, but my code doesn't seem to work properly:

Code: Select all
unit HImageList;

interface

uses
  Windows, Messages, SysUtils, Classes, ImgList, Controls, Graphics,
  HColorUtitles, CommCtrl;

type
  THImageList = class(TImageList)
  private
    { Private declarations }
  protected
    procedure DoDraw(Index: Integer; Canvas: TCanvas; X, Y: Integer;
      Style: Cardinal; Enabled: Boolean = True);override;
  public
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

{$R *.dcr}

procedure Register;
begin
  RegisterComponents('HAKGERSoft Components', [THImageList]);
end;

//Special constans

const
  DrawingStyles: array[TDrawingStyle] of Longint = (ILD_FOCUS, ILD_SELECTED,
    ILD_NORMAL, ILD_TRANSPARENT);
  Images: array[TImageType] of Longint = (0, ILD_MASK);

//functions needed

function GetRGBColor(Value: TColor): DWORD;
begin
  Result := ColorToRGB(Value);
  case Result of
    clNone: Result := CLR_NONE;
    clDefault: Result := CLR_DEFAULT;
  end;
end;

function GetColor(Value: DWORD): TColor;
begin
  case Value of
    CLR_NONE: Result := clNone;
    CLR_DEFAULT: Result := clDefault;
  else
    Result := TColor(Value);
  end;
end;

{ THImageList }

procedure THImageList.DoDraw(Index: Integer; Canvas: TCanvas; X,
  Y: Integer; Style: Cardinal; Enabled: Boolean);
type
  pRGBTripleArray=^TRGBTripleArray;
  TRGBTripleArray=array [Word] of TRGBTriple;

  function CompareRGB(RGB1: TRGBTriple; RGB2: TRGBTriple): Boolean;
  begin
    Result:=(RGB1.rgbtBlue=RGB2.rgbtBlue) and (RGB1.rgbtGreen=RGB2.rgbtGreen)
      and (RGB1.rgbtRed=RGB2.rgbtRed);
  end;

const
  ROP_DSPDxax = $00E20746;
var
  FBitmap: TBitmap;
  Row: pRGBTripleArray;
  rX, rY: Integer;
  RGB, RGBTransparent: TRGBTriple;
begin
  if Enabled then
    begin
      inherited;
      Exit;
    end
  else
    begin
      if HandleAllocated then
        begin
          FBitmap:=TBitmap.Create;
          With FBitmap do
            begin
              Width:=Self.Width;
              Height:=Self.Height;
              PixelFormat:=pf24Bit;
            end;
          FBitmap.Canvas.Brush.Color := clWhite;
          FBitmap.Canvas.FillRect(Rect(0, 0, Self.Width, Self.Height));
          ImageList_DrawEx(Handle, Index, FBitmap.Canvas.Handle, 0,0,0,0,
            CLR_NONE, 0, ILD_NORMAL);
          for rY:=0 to FBitmap.Height-1 do
            begin
              Row:=FBitmap.ScanLine[rY];
              for rX:=0 to FBitmap.Width-1 do
                begin
                  If (rX=0) and (rY=0) then
                    begin
                      RGBtransparent:=Row[rX];
                      Continue;
                    end;
                  RGB:=Row[rX];
                  If CompareRGB(RGB, RGBTransparent) then
                    Continue;
                  Row[X].rgbtBlue:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                  Row[X].rgbtGreen:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                  Row[X].rgbtRed:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                end;
            end;
          Canvas.Draw(X, Y, FBitmap);
        end;
    end;
end;

end.


It draws bitmap, but not in color I Want, and also when bitmap is in TMenuItem, when Menuitem is selected, then funny thing happends:
Image

What I Do wrong?
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » August 4th, 2003, 5:01 pm

Can you please explain what the new method should do?

Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Johnny_Bit » August 5th, 2003, 2:07 pm

simply draws disabled bitmaps. for toolbar, i create other imagelist and set it to DisabledGlyphs, code for generate ne image list with disabled items looks like that:
Code: Select all
procedure GrayImgList(Inp: TImageList; Outp: TImageList);

  function CompareRGB(RGB1: TRGBTriple; RGB2: TRGBTriple): Boolean;
  begin
    Result:=(RGB1.rgbtBlue=RGB2.rgbtBlue) and (RGB1.rgbtGreen=RGB2.rgbtGreen)
      and (RGB1.rgbtRed=RGB2.rgbtRed);
  end;

type
  pRGBTripleArr=^RGBTripleArr;
  RGBTripleArr=packed array[word] of TRGBTriple;
var
  X, Y, I: Integer;
  Row: pRGBTripleArr;
  BMP: TBitmap;
  RGB, RGBTransparent: TRGBTriple;
begin
  if (inp=nil) or (outp=nil) then
    Exit;
  for I:=0 to Inp.Count-1 do
    begin
      BMP:=TBitmap.Create;
      BMP.Width:=Inp.Width;
      BMP.Height:=Inp.Height;
      BMP.PixelFormat:=pf24bit;
      Inp.GetBitmap(I, BMP);
      for Y:=0 to BMP.Height-1 do
        begin
          Row:=BMP.ScanLine[Y];
          for X:=0 to BMP.Width-1 do
            begin
              If (X=0) and (Y=0) then
                begin
                  RGBtransparent:=Row[X];
                  Continue;
                end;
              RGB:=Row[X];
              If CompareRGB(RGB, RGBTransparent) then
                Continue;
              Row[X].rgbtBlue:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
              Row[X].rgbtGreen:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
              Row[X].rgbtRed:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
            end;
        end;
      Outp.AddMasked(BMP, BMP.Canvas.Pixels[0, 0]);
      BMP.Free;
    end;
end;


and it works perfectly
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Johnny_Bit » August 5th, 2003, 3:35 pm

I changed code a bit:
Code: Select all
unit HImageList;

interface

uses
  Windows, Messages, SysUtils, Classes, ImgList, Controls, Graphics,
  HColorUtitles, CommCtrl;

type
  THImageList = class(TImageList)
  private
    { Private declarations }
  protected
    procedure DoDraw(Index: Integer; Canvas: TCanvas; X, Y: Integer;
      Style: Cardinal; Enabled: Boolean = True);override;
  public
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

{$R *.dcr}

procedure Register;
begin
  RegisterComponents('HAKGERSoft Components', [THImageList]);
end;

//Special constans

const
  DrawingStyles: array[TDrawingStyle] of Longint = (ILD_FOCUS, ILD_SELECTED,
    ILD_NORMAL, ILD_TRANSPARENT);
  Images: array[TImageType] of Longint = (0, ILD_MASK);

//functions needed

function GetRGBColor(Value: TColor): DWORD;
begin
  Result := ColorToRGB(Value);
  case Result of
    clNone: Result := CLR_NONE;
    clDefault: Result := CLR_DEFAULT;
  end;
end;

function GetColor(Value: DWORD): TColor;
begin
  case Value of
    CLR_NONE: Result := clNone;
    CLR_DEFAULT: Result := clDefault;
  else
    Result := TColor(Value);
  end;
end;

{ THImageList }

procedure THImageList.DoDraw(Index: Integer; Canvas: TCanvas; X,
  Y: Integer; Style: Cardinal; Enabled: Boolean);
type
  pRGBTripleArray=^TRGBTripleArray;
  TRGBTripleArray=array [Word] of TRGBTriple;

  function CompareRGB(RGB1: TRGBTriple; RGB2: TRGBTriple): Boolean;
  begin
    Result:=(RGB1.rgbtBlue=RGB2.rgbtBlue) and (RGB1.rgbtGreen=RGB2.rgbtGreen)
      and (RGB1.rgbtRed=RGB2.rgbtRed);
  end;

const
  ROP_DSPDxax = $00E20746;
var
  FBitmap: TBitmap;
  Row: pRGBTripleArray;
  rX, rY: Integer;
  RGB: TRGBTriple;
begin
  if Enabled then
    begin
      inherited;
      Exit;
    end
  else
    begin
      if HandleAllocated then
        begin
          FBitmap:=TBitmap.Create;
          With FBitmap do
            begin
              Width:=Self.Width;
              Height:=Self.Height;
              PixelFormat:=pf24Bit;
            end;
          FBitmap.Canvas.Brush.Color := clWhite;
          FBitmap.Canvas.FillRect(Rect(0, 0, Self.Width, Self.Height));
          ImageList_DrawEx(Handle, Index, FBitmap.Canvas.Handle, 0,0,0,0,
            CLR_NONE, 0, ILD_NORMAL);
          for rY:=0 to FBitmap.Height-1 do
            begin
              Row:=FBitmap.ScanLine[rY];
              for rX:=0 to FBitmap.Width-1 do
                begin
                  RGB:=Row[rX];
                  If GetColor(Windows.RGB(Row[rX].rgbtRed, Row[rX].rgbtGreen, Row[rX].rgbtBlue))=clNone then
                    Continue;
                  Row[rX].rgbtBlue:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                  Row[rX].rgbtGreen:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                  Row[rX].rgbtRed:=RGBToLightness(RGB.rgbtRed, RGB.rgbtGreen, RGB.rgbtBlue);
                end;
            end;
          Canvas.Draw(X, Y, FBitmap);
        end;
    end;
end;

end.


and now it works as it should, well not exacly:
Image

images in red elipse 1 should be exacly same as images in red elypse 2, but they aren't. area that should be transparent is white. why? and how to repair it?
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » August 5th, 2003, 7:16 pm

Probably if before drawing FBitmap on the Canvas you set its TransparentColor to clWhite, the problem is solved.

Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Johnny_Bit » August 6th, 2003, 1:44 pm

Thank You, again. that was it, but clWhite shouldn't be used it this case, so I filled bitmap wit clFuchasia and set transparent color to clFuchasia, and it works very good.

One more thing:

Image generated in this way is only grayed version of orginal image, but I want it also to drop a shaddow (one pixel wide shadow) how to do it? i konow, that orginal procedure DoDraw have it
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » August 6th, 2003, 8:44 pm

An efficient algorithm for drawing an image with dropped shadow is too complicated. To have a good shadow you have to do the following steps:
    Claculate the Gussian Blur of the image according to the shadow size you want.
    Calculate the shadow offset related to the original image's position according to the angle of the shadow.
    Use the Gussian Blur from the previous step as alpha channel and draw pixels with the color of the shadow.
    Draw the original image as anti-aliased transparent
After that the final result could be something like the following screenshot: :wink:

Image

The above screenshot shows one of my component, which is a toolbar capable to draw icons as shadowed. In the screenshot you can see also some buttons as disabled, and mouse is over the first icon of the vertical toolbar. When mouse is down on an icon, the icon will look as pressed.

Well, so far I have no plan to release the toolbar component in the screenshot, or my image filter library to public domain. :oops:

You can see the toolbar component it in action in QualiWORLD. The program is available to download at http://www.qualilife.com.

Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Johnny_Bit » August 7th, 2003, 6:18 pm

funny thing, i think just to conver image non transparent araes to clBtnHighlight or somethin' like that, and draw it just pixel left and pixel down from orginal request, then draw normal grayed, and it will work! thank you for answer i think i use it in my other programs
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Here my unit, maybe will be usefull for You

Postby Karabumb » August 18th, 2003, 6:40 pm

Code: Select all
unit BlurImage;

interface

uses Windows, Graphics, SysUtils;

type
  TCol = record
    r: byte;
    g: byte;
    b: byte;
    end;

function RGBToBGR(Color:cardinal):TCol;
procedure rgbTObrgTOgbr(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
procedure HorisontalBlur(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
procedure VerticalBlur(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
procedure HVBlur(BitMap:Tbitmap;NumberOfSteps:byte;Left,Top,Right,Bottom:cardinal);

implementation


function RGBToBGR(Color:cardinal):TCol;
begin
Result.r := byte((pointer(cardinal(@Color) + 2))^);
Result.g := byte((pointer(cardinal(@Color) + 1))^);
Result.b := byte((pointer(cardinal(@Color) + 0))^);
end;


procedure rgbTObrgTOgbr(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
type TWorkType = record
     NumA,NumB,NumC: cardinal;
     end;
const
Num: TWorkType = (NumA:0;NumB:0;NumC:0);
WorkVar: TCol = (r:0;g:0;b:0);
ScanLinePoint: pointer = nil;
Decr: cardinal = 0;
var
PosX: cardinal;
PosY: cardinal;
begin
ScanLinePoint := BitMap.ScanLine[0];
Decr := cardinal(ScanLinePoint) - cardinal(BitMap.ScanLine[1]);
Inc(cardinal(ScanLinePoint),Decr);
for PosY := Top to Bottom do
    begin
    Dec(cardinal(ScanLinePoint),Decr);
    for PosX := Left to Right do
        begin
        Num.NumA := PosX * 3;
        Num.NumB := Num.NumA + 1;
        Num.NumC := Num.NumB + 1;
        WorkVar.r := byte(pointer(cardinal(ScanLinePoint) + Num.NumA)^);
        WorkVar.g := byte(pointer(cardinal(ScanLinePoint) + Num.NumB)^);
        WorkVar.b := byte(pointer(cardinal(ScanLinePoint) + Num.NumC)^);
        byte(pointer(cardinal(ScanLinePoint) + Num.NumA)^) := WorkVar.b;
        byte(pointer(cardinal(ScanLinePoint) + Num.NumB)^) := WorkVar.r;
        byte(pointer(cardinal(ScanLinePoint) + Num.NumC)^) := WorkVar.g;
        end;
    end;
end;


procedure HorisontalBlur(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
type TWorkTypeB = record
     LNumA,LNumB,LNumC: byte;
     CNumA,CNumB,CNumC: byte;
     RNumA,RNumB,RNumC: byte;
     end;
     TWorkTypeC = record
     LNumA,LNumB,LNumC: cardinal;
     CNumA,CNumB,CNumC: cardinal;
     RNumA,RNumB,RNumC: cardinal;
     end;
const
ScanLinePoint: pointer = nil;
NumCol: TWorkTypeB = (LNumA:0;LNumB:0;LNumC:0;CNumA:0;CNumB:0;CNumC:0;RNumA:0;RNumB:0;RNumC:0);
Position: TWorkTypeC = (LNumA:0;LNumB:0;LNumC:0;CNumA:0;CNumB:0;CNumC:0;RNumA:0;RNumB:0;RNumC:0);
Decr: cardinal = 0;
var
PosX,PosY: cardinal;
begin
ScanLinePoint := BitMap.ScanLine[0];
Decr := cardinal(ScanLinePoint) - cardinal(BitMap.ScanLine[1]);
Inc(cardinal(ScanLinePoint),Decr);
Dec(cardinal(ScanLinePoint),Decr * Top);
for PosY := Top to Bottom do
    begin
    Dec(cardinal(ScanLinePoint),Decr);
    //MessageBox(0,pchar(IntToStr(cardinal(BitMap.ScanLine[PosY]))+' - '+IntToStr(cardinal(ScanLinePoint))),'',MB_OK);
    for PosX := Left to Right do
        begin
        Position.CNumA := PosX * 3;
        Position.CNumB := Position.CNumA + 1;
        Position.CNumC := Position.CNumA + 2;
        NumCol.CNumA := byte((pointer(cardinal(ScanLinePoint) + Position.CNumA))^);
        NumCol.CNumB := byte((pointer(cardinal(ScanLinePoint) + Position.CNumB))^);
        NumCol.CNumC := byte((pointer(cardinal(ScanLinePoint) + Position.CNumC))^);
        if (PosX <> Left) and (PosX <> Right) then
           begin
           Position.LNumA := Position.CNumA - 3;
           Position.LNumB := Position.CNumA - 2;
           Position.LNumC := Position.CNumA - 1;
           Position.RNumA := Position.CNumA + 3;
           Position.RNumB := Position.CNumA + 4;
           Position.RNumC := Position.CNumA + 5;
           NumCol.LNumA := byte((pointer(cardinal(ScanLinePoint) + Position.LNumA))^);
           NumCol.LNumB := byte((pointer(cardinal(ScanLinePoint) + Position.LNumB))^);
           NumCol.LNumC := byte((pointer(cardinal(ScanLinePoint) + Position.LNumC))^);
           NumCol.RNumA := byte((pointer(cardinal(ScanLinePoint) + Position.RNumA))^);
           NumCol.RNumB := byte((pointer(cardinal(ScanLinePoint) + Position.RNumB))^);
           NumCol.RNumC := byte((pointer(cardinal(ScanLinePoint) + Position.RNumC))^);
           NumCol.CNumA := (NumCol.CNumA + NumCol.LNumA + NumCol.RNumA) div 3;
           NumCol.CNumB := (NumCol.CNumB + NumCol.LNumB + NumCol.RNumB) div 3;
           NumCol.CNumC := (NumCol.CNumC + NumCol.LNumC + NumCol.RNumC) div 3;
           end else
           begin
           if PosX = Left then
              begin
              Position.RNumA := Position.CNumA + 3;
              Position.RNumB := Position.CNumA + 4;
              Position.RNumC := Position.CNumA + 5;
              NumCol.RNumA := byte((pointer(cardinal(ScanLinePoint) + Position.RNumA))^);
              NumCol.RNumB := byte((pointer(cardinal(ScanLinePoint) + Position.RNumB))^);
              NumCol.RNumC := byte((pointer(cardinal(ScanLinePoint) + Position.RNumC))^);
              NumCol.CNumA := (NumCol.CNumA + NumCol.RNumA) div 2;
              NumCol.CNumB := (NumCol.CNumB + NumCol.RNumB) div 2;
              NumCol.CNumC := (NumCol.CNumC + NumCol.RNumC) div 2;
              end;
           if PosX = Right then
              begin
              Position.LNumA := Position.CNumA - 3;
              Position.LNumB := Position.CNumA - 2;
              Position.LNumC := Position.CNumA - 1;
              NumCol.LNumA := byte((pointer(cardinal(ScanLinePoint) + Position.LNumA))^);
              NumCol.LNumB := byte((pointer(cardinal(ScanLinePoint) + Position.LNumB))^);
              NumCol.LNumC := byte((pointer(cardinal(ScanLinePoint) + Position.LNumC))^);
              NumCol.CNumA := (NumCol.CNumA + NumCol.LNumA) div 2;
              NumCol.CNumB := (NumCol.CNumB + NumCol.LNumB) div 2;
              NumCol.CNumC := (NumCol.CNumC + NumCol.LNumC) div 2;
              end;
           end;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumA)^) := NumCol.CNumA;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumB)^) := NumCol.CNumB;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumC)^) := NumCol.CNumC;
        end;
    end;
end;


procedure VerticalBlur(BitMap:TBitMap;Left,Top,Right,Bottom:cardinal);
type TWorkTypeB = record
     TNumA,TNumB,TNumC: byte;
     CNumA,CNumB,CNumC: byte;
     BNumA,BNumB,BNumC: byte;
     end;
     TWorkTypeC = record
     CNumA,CNumB,CNumC: cardinal;
     end;
const
ScanLinePoint: pointer = nil;
TScanLinePoint: pointer = nil;
BScanLinePoint: pointer = nil;
NumCol: TWorkTypeB = (TNumA:0;TNumB:0;TNumC:0;CNumA:0;CNumB:0;CNumC:0;BNumA:0;BNumB:0;BNumC:0);
Position: TWorkTypeC = (CNumA:0;CNumB:0;CNumC:0);
Decr: cardinal = 0;
var
PosX,PosY: cardinal;
begin
ScanLinePoint := BitMap.ScanLine[0];
Decr := cardinal(ScanLinePoint) - cardinal(BitMap.ScanLine[1]);
Inc(cardinal(ScanLinePoint),Decr);
Dec(cardinal(ScanLinePoint),Decr * Top);
for PosY := Top to Bottom do
    begin
    Dec(cardinal(ScanLinePoint),Decr);
    for PosX := Left to Right do
        begin
        Position.CNumA := PosX * 3;
        Position.CNumB := Position.CNumA + 1;
        Position.CNumC := Position.CNumA + 2;
        NumCol.CNumA := byte((pointer(cardinal(ScanLinePoint) + Position.CNumA))^);
        NumCol.CNumB := byte((pointer(cardinal(ScanLinePoint) + Position.CNumB))^);
        NumCol.CNumC := byte((pointer(cardinal(ScanLinePoint) + Position.CNumC))^);
        if (PosY <> Top) and (PosY <> Bottom) then
           begin
           cardinal(TScanLinePoint) := cardinal(ScanLinePoint) + Decr;
           cardinal(BScanLinePoint) := cardinal(ScanLinePoint) - Decr;
           NumCol.TNumA := byte((pointer(cardinal(TScanLinePoint) + Position.CNumA))^);
           NumCol.TNumB := byte((pointer(cardinal(TScanLinePoint) + Position.CNumB))^);
           NumCol.TNumC := byte((pointer(cardinal(TScanLinePoint) + Position.CNumC))^);
           NumCol.BNumA := byte((pointer(cardinal(BScanLinePoint) + Position.CNumA))^);
           NumCol.BNumB := byte((pointer(cardinal(BScanLinePoint) + Position.CNumB))^);
           NumCol.BNumC := byte((pointer(cardinal(BScanLinePoint) + Position.CNumC))^);
           NumCol.CNumA := (NumCol.TNumA + NumCol.CNumA + NumCol.BNumA) div 3;
           NumCol.CNumB := (NumCol.TNumB + NumCol.CNumB + NumCol.BNumB) div 3;
           NumCol.CNumC := (NumCol.TNumC + NumCol.CNumC + NumCol.BNumC) div 3;
           end else
           begin
           if PosY = Top then
              begin
              cardinal(BScanLinePoint) := cardinal(ScanLinePoint) - Decr;
              NumCol.BNumA := byte((pointer(cardinal(BScanLinePoint) + Position.CNumA))^);
              NumCol.BNumB := byte((pointer(cardinal(BScanLinePoint) + Position.CNumB))^);
              NumCol.BNumC := byte((pointer(cardinal(BScanLinePoint) + Position.CNumC))^);
              NumCol.CNumA := (NumCol.CNumA + NumCol.BNumA) div 2;
              NumCol.CNumB := (NumCol.CNumB + NumCol.BNumB) div 2;
              NumCol.CNumC := (NumCol.CNumC + NumCol.BNumC) div 2;
              end;
           if PosY = Bottom then
              begin
              cardinal(TScanLinePoint) := cardinal(ScanLinePoint) + Decr;
              NumCol.TNumA := byte((pointer(cardinal(TScanLinePoint) + Position.CNumA))^);
              NumCol.TNumB := byte((pointer(cardinal(TScanLinePoint) + Position.CNumB))^);
              NumCol.TNumC := byte((pointer(cardinal(TScanLinePoint) + Position.CNumC))^);
              NumCol.CNumA := (NumCol.TNumA + NumCol.CNumA) div 2;
              NumCol.CNumB := (NumCol.TNumB + NumCol.CNumB) div 2;
              NumCol.CNumC := (NumCol.TNumC + NumCol.CNumC) div 2;
              end;
           end;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumA)^) := NumCol.CNumA;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumB)^) := NumCol.CNumB;
        byte(pointer(cardinal(ScanLinePoint) + Position.CNumC)^) := NumCol.CNumC;
        end;
    end;
end;

procedure HVBlur(BitMap:Tbitmap;NumberOfSteps:byte;Left,Top,Right,Bottom:cardinal);
var
Num: byte;
begin
for Num := 1 to NumberOfSteps do
    begin
    HorisontalBlur(BitMap,Left,Top,Right,Bottom);
    VerticalBlur(BitMap,Left,Top,Right,Bottom);
    end;
end;

end.
Karabumb
Member
Member
 
Posts: 2
Joined: August 18th, 2003, 5:43 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron