![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Сдвиг Red канала на X, Y пикселей [D7, WinXP]
h8394E © (2006-05-04 02:10:00)Доброго времени суток. А как сдвинуть канал Red на определённое число пикселей?
antonn (2006-05-04 15:13:00) [1]ах да, к предыдущему посту:
const
Pixels = MaxInt div SizeOf(TRGBTriple);
type
PRGBArray = ^TRGBArray;
TRGBArray = array[0..Pixels-1] of TRGBTriple;
antonn (2006-05-04 15:12:00) [2]
procedure Sdvig_chanal(_B_out:Tbitmap; _x,_y:integer; c:byte);
var x, y, x_cor,y_cor,x_corS,y_corS: Integer; RowOut,RowIn: PRGBArray;
_r,_b,_g:integer; rc1, bc1, gc1:byte;
_Rect:TRect; BT:Tbitmap;
begin
_Rect.Left:=_x; _Rect.Top:=_y;
_Rect.Right:=_B_out.Width+_x; _Rect.Bottom:=_B_out.Height+_y;
if _Rect.Left<0 then _Rect.Left:=0;
if _Rect.Top<0 then _Rect.Top:=0;
if _Rect.Right>_B_out.Width then _Rect.Right:=_B_out.Width;
if _Rect.Bottom>_B_out.Height then _Rect.Bottom:=_B_out.Height;
BT:=TBitmap.Create;
try
BT.Assign(_B_out);
BT.PixelFormat:=pf24bit;
_B_out.PixelFormat:=pf24bit;
for y:=_Rect.Top to _Rect.Bottom-1 do begin
RowOut:= _B_out.ScanLine[y];
RowIn:= BT.ScanLine[y-_y];
for x:=_Rect.Left to _Rect.Right-1 do begin
case c of
0: RowOut[x].rgbtRed:=RowIn[x-_x].rgbtRed;
1: RowOut[x].rgbtGreen:=RowIn[x-_x].rgbtGreen;
2: RowOut[x].rgbtBlue:=RowIn[x-_x].rgbtBlue;
end;
end;
end;
finally
Bt.Free;
end;
end;
немного коряво, но работает...
последний параметр - выбирает канал (0-R, 1-G, 2-B), картинка преобразуется в pf24bit.
для сдвига альфаканала можно доработать самому.
Jeer (2006-05-04 10:06:00) [3]h8394E (04.05.06 02:10)
> как сдвинуть канал Red
В какую сторону, смотря.
antonn (2006-05-04 07:02:00) [4]если в TBitmap, то воспользоваться scanline()