Программирование
Главная » FAQ |
procedure TForm1.Button1Click(Sender: TObject); var Line: pByteArray; i, j: integer; begin // Считываем высоту картинки for i := 0 to Image1.Picture.Bitmap.Height - 1 do begin // Сканируем по линиям рисунок Line := Image1.Picture.Bitmap.ScanLine[i]; for j := 0 to Image1.Picture.Bitmap.Width * 3 - 1 do // Меняем цвет на обратный исходя из RGB Line^[j] := 255 - Line^[j]; end; Image1.Refresh; end; |
procedure Spray( Canvas: TCanvas; x, y, r: Integer; Color: TColor ); rad, a: Single; i: Integer; begin for i := 0 to 100 do begin a := Random * 2 * pi; rad := Random * r; Canvas.Pixels[x + Round( rad * Cos( a ) ), y + Round( rad * Sin( a ) )] := Color; end; end; procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if ssLeft in Shift then Spray( Image1.Canvas, x, y, 40, clRed ); end; procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if ssLeft in Shift then Spray( Image1.Canvas, x, y, 40, clRed ); end; |
function TForm1.DeleteDir(Dir: string): boolean; isFound: boolean; sRec: TSearchRec; begin Result := false; ChDir( Dir ); if IOResult <> 0 then begin ShowMessage( 'Не могу войти в каталог: ' + Dir ); Exit; end; isFound := FindFirst( '*.*', faAnyFile, sRec ) = 0; while isFound do begin if ( sRec.Name <> '.' ) and ( sRec.Name <> '..' ) then if ( sRec.Attr and faDirectory ) = faDirectory then begin if not DeleteDir( sRec.Name ) then Exit; end else if not DeleteFile( sRec.Name ) then begin ShowMessage( 'Не могу удалить файл: ' + sRec.Name ); Exit; end; isFound := FindNext( sRec ) = 0; end; FindClose( sRec ); ChDir( '..' ); RmDir( Dir ); Result := IOResult = 0; end; |
|
function GetAttribut( Path: string ): string; Atr: Integer; begin Result := '----'; Atr := FileGetAttr( Path ); if ( Atr and faReadOnly ) = faReadOnly then Result[1] := 'r'; if ( Atr and faHidden ) = faHidden then Result[2] := 'h'; if ( Atr and faSysFile ) = faSysFile then Result[3] := 's'; if ( Atr and faArchive ) = faArchive then Result[4] := 'a'; end; |