Advertisement
mixster

Untitled

Dec 20th, 2011
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.96 KB | None | 0 0
  1. function CommonColorBMP(Bmp : Integer; Index :Integer) :Integer;
  2. var
  3.   Target, W, H, I, Hi, I2, Hi2, Hi3, C: integer;
  4.   ColArr, CountArr :TIntegerArray;
  5.   ColorArr :T2DIntegerArray;
  6.  
  7. begin
  8.   GetBitmapSize(Bmp, W, H);
  9.   ColorArr := GetBitmapAreaColors(Bmp, 0, 0, W - 1, H - 1);
  10.   Hi := High(ColorArr);
  11.   Hi2 := High(ColorArr[i]);
  12.   C := 0;
  13.   for I := 0 to Hi do
  14.     for I2 := 0 to Hi2 do
  15.       begin
  16.         If InIntArray([2171169, 526344, 460551, 131072, 0], ColorArr[I][I2]) then Continue;
  17.         SetLength(CountArr, C + 1);
  18.         SetLength(ColArr, C + 1);
  19.         ColArr[C] := ColorArr[I][I2];
  20.         CountArr[C] := CountColor(ColArr[I], 0, 0, W - 1, H - 1);
  21.         Inc(C);
  22.       end;
  23.  
  24.   ClearSameIntegers(ColArr);
  25.   ClearSameIntegers(CountArr);
  26.   Quicksort(CountArr);
  27.   InvertTIA(CountArr);
  28.  
  29.   Hi3 := High(ColArr);
  30.   for I := 0 to Hi3 do
  31.     If CountColor(ColArr[I], 0, 0, W - 1, H - 1) = CountArr[Index] then
  32.       Result := ColArr[I];
  33. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement