function MyGetMem(Size: DWORD): Pointer;
begin
Result := Pointer(GlobalAlloc(GPTR, Size));
end;
procedure MyFreeMem(p: Pointer);
begin
if p = nil then Exit;
GlobalFree(THandle(p));
end;
{ This code will fill a bitmap by stretching an image coming from a big bitmap on disk.
FileName.- Name of the uncompressed bitmap to read
DestBitmap.- Target bitmap where the bitmap on disk will be resampled.
BufferSize.- The size of a memory buffer used for reading scanlines from the physical bitmap on disk.
This value will decide how many scanlines can be read from disk at the same time, with always a
minimum value of 2 scanlines.
Read more »
Filed in Графика by admin | Февраль 27, 2008 | No Comments
unit Unit1;
interface
uses
Windows, Classes, SysUtils, Graphics, Forms;
type
TRGBArray = array[0..32767] of TRGBTriple;
PRGBArray = ^TRGBArray;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FRegion: THandle;
function CreateRegion(Bmp: TBitmap): THandle;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Read more »
Filed in Графика by admin | Февраль 27, 2008 | No Comments
Вот кусок одного моего класса, в котором есть две интересные вещицы - проецирование файлов в память и работа с битмэпом в памяти через указатель.
Сразу оговорюсь, что все это работает только под Win95/NT.
type
TarrRGBTriple = array[byte] of TRGBTriple;
ParrRGBTriple = ^TarrRGBTriple;
{организует битмэп размером SX,SY;true_color}
procedure TMBitmap.Allocate(SX, SY: integer);
var
DC: HDC;
begin
if BM <> 0 then
DeleteObject(BM); {удаляем старый битмэп, если был}
BM := 0;
PB := nil;
fillchar(BI, sizeof(BI), 0); Read more »
Filed in Графика by admin | Февраль 27, 2008 | No Comments
procedure TForm1.Button1Click(Sender: TObject);
var
TheIcon: TIcon;
TheBitmap: TBitmap;
begin
TheIcon := TIcon.Create;
TheIcon.LoadFromFile(’C:\Program Files\Borland\IcoCur32\EARTH.ICO’);
TheBitmap := TBitmap.Create;
TheBitmap.Height := TheIcon.Height;
TheBitmap.Width := TheIcon.Width;
TheBitmap.Canvas.Draw(0, 0, TheIcon);
Form1.Canvas.Draw(10, 10, TheBitmap);
TheBitmap.Free;
TheIcon.Free;
end;
Filed in Графика by admin | Февраль 27, 2008 | No Comments
Способ преобразования изображения размером 32×32 в иконку.
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Read more »
Filed in Графика by admin | Февраль 27, 2008 | No Comments