Показать сообщение отдельно
  #2  
Старый 26.05.2008, 18:21
lmikle lmikle вне форума
Модератор
 
Регистрация: 17.04.2008
Сообщения: 8,097
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
По умолчанию

м-м-м...
Ну проверять надо, но должно быть что-то типа:

Код:
var
  Image : TBitmap;

// Загрузка
procedure LoadBitmap(AFileName : String); // AFileName - полное имя файла
begin
  If Not Assiged(Image) Then Image := TBitmap.Create;
  Try
    Image.LoadFromFile(AFileName);
  Excpet
    FreeAndNil(Image);
    Raise;
  End;
end;

// Освобождение. Вызывается после окончания работы с картинкой
procedure FreeBitmap;
begin
  If Assiged(Image) Then FreeAndNil(Image);
end;

// Рисуем кружок
procedure DrawCircle(X, Y, R : Integer);
begin
  If Not Assiged(Image) Then 
    Raise Exception.Create('Image doesn''t loaded.');

  // Здесь, возможно, надо еще настроить кисть и карандаш
  Image.Canvas.Ellipse(Rect(X-R,Y-R,X+R,Y+R));
end;

// Сохраняем кусок
procedure SaveBitmapPart(X,Y,W,H : Integer; AFileName : String);
var
  Buf : TBitmap;
begin
  Buf := TBitmap.Create;
  Try
    Buf.PixelFormat := pf24Bit;
    Buf.Width := W;
    Buf.Height := H;
    Buf.CopyRect(Rect(0,0,W,H),Image.Canvas,Rect(x,y,x+W,y+W));
    Buf.SaveToFile(AFileName);
  Finally
    Buf.Free;
  End;
end;

exports
  LoadBitmap,
  FreeBitmap,
  DrawCircle,
  SaveBitmapPart;
  
Ответить с цитированием