Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.09.05;
Скачать: [xml.tar.bz2];

Вниз

Помогите с Image ом   Найти похожие ветки 

 
[BAD]Angel   (2002-08-27 13:00) [0]

Люди, подскажите, есть какая нить компонента или как сделать программно, чтобы картинка вращалась (поворачивалась на какой-то угол)???


 
Skier   (2002-08-27 13:02) [1]

>[BAD]Angel
www.torry.net не поможет ?


 
[BAD]Angel   (2002-08-27 13:04) [2]

А точнее? ;-)


 
{bas}   (2002-08-27 13:05) [3]

Вот когда-то нашел

{Turn off Range Checking because of ARRAY[0..0] construct below}

{$R-}

unit Bitmap;

interface

uses
Windows, Graphics;

procedure MirrorHorizontal(Bitmap: TBitmap);
procedure MirrorVertical(Bitmap: TBitmap);
procedure Rotate90Degrees(Bitmap: TBitmap);
procedure Rotate270Degrees(Bitmap: TBitmap);
procedure Rotate180Degrees(Bitmap: TBitmap);

implementation

uses
dialogs, Classes, SysUtils;

type
EBitmapError = Class(Exception);
TRGBArray = Array[0..0] of TRGBTriple;
pRGBArray = ^TRGBArray;

procedure MirrorHorizontal(Bitmap: TBitmap);
var
i, j, w: Integer;
RowIn: pRGBArray;
RowOut: pRGBArray;
begin
w := bitmap.width * sizeof(TRGBTriple);
GetMem(rowin, w);
for j := 0 to Bitmap.Height - 1 do
begin
move(Bitmap.Scanline[j]^, rowin^, w);
rowout := Bitmap.Scanline[j];
for i := 0 to Bitmap.Width - 1 do
rowout[i] := rowin[Bitmap.Width - 1 - i];
end;
bitmap.Assign(bitmap);
FreeMem(rowin);
end;


procedure MirrorVertical(Bitmap : TBitmap);
var
j, w: Integer;
help: TBitmap;
begin
help := TBitmap.Create;
help.Width := Bitmap.Width;
help.Height := Bitmap.Height;
help.PixelFormat := Bitmap.PixelFormat;
w := Bitmap.Width * sizeof(TRGBTriple);
for j := 0 to Bitmap.Height - 1 do
move(Bitmap.Scanline[j]^, Help.Scanline[Bitmap.Height - 1 - j]^, w);
Bitmap.Assign(help);
help.free;
end;


type
THelpRGB = packed record
rgb: TRGBTriple;
dummy: byte;
end;


procedure Rotate270Degrees(Bitmap: TBitmap);
var
aStream: TMemorystream;
header: TBITMAPINFO;
dc: hDC;
P: ^THelpRGB;
x, y, b, h: Integer;
RowOut: pRGBArray;
begin
aStream := TMemoryStream.Create;
aStream.SetSize(Bitmap.Height * Bitmap.Width * 4);
with header.bmiHeader do
begin
biSize := SizeOf(TBITMAPINFOHEADER);
biWidth := Bitmap.Width;
biHeight := Bitmap.Height;
biPlanes := 1;
biBitCount := 32;
biCompression := 0;
biSizeimage := aStream.Size;
biXPelsPerMeter :=1;
biYPelsPerMeter :=1;
biClrUsed :=0;
biClrImportant :=0;
end;
dc := GetDC(0);
P := aStream.Memory;
GetDIBits(dc,Bitmap.Handle, 0, Bitmap.Height, P,header, dib_RGB_Colors);
ReleaseDC(0, dc);
b := bitmap.Height; {rotate}
h := bitmap.Width; {rotate}
bitmap.Width := b;
bitmap.height := h;
for y := 0 to (h - 1) do
begin
rowOut := Bitmap.ScanLine[(h - 1) - y];
P := aStream.Memory; {reset pointer}
inc(p, y);
for x := (b - 1) downto 0 do
begin
rowout[x] := p^.rgb;
inc(p, h);
end;
end;
aStream.Free;
end;


procedure Rotate90Degrees(Bitmap: TBitmap);
var
aStream: TMemorystream;
header: TBITMAPINFO;
dc: hDC;
P: ^THelpRGB;
x, y, b, h: Integer;
RowOut: pRGBArray;
begin
aStream := TMemoryStream.Create;
aStream.SetSize(Bitmap.Height * Bitmap.Width * 4);
with header.bmiHeader do
begin
biSize := SizeOf(TBITMAPINFOHEADER);
biWidth := Bitmap.Width;
biHeight := Bitmap.Height;
biPlanes := 1;
biBitCount := 32;
biCompression := 0;
biSizeimage := aStream.Size;
biXPelsPerMeter :=1;
biYPelsPerMeter :=1;
biClrUsed :=0;
biClrImportant :=0;
end;
dc := GetDC(0);
P := aStream.Memory;
GetDIBits(dc, Bitmap.Handle, 0, Bitmap.Height, P, header, dib_RGB_Colors);
ReleaseDC(0, dc);
b := bitmap.Height; {rotate}
h := bitmap.Width; {rotate}
bitmap.Width := b;
bitmap.height := h;
for y := 0 to (h - 1) do
begin
rowOut := Bitmap.ScanLine[y];
P := aStream.Memory; {reset pointer}
inc(p, y);
for x := 0 to (b - 1) do
begin
rowout[x] := p^.rgb;
inc(p, h);
end;
end;
aStream.Free;
end;


procedure Rotate180Degrees(Bitmap: TBitmap);
var
i, j: Integer;
rowIn: pRGBArray;
rowOut: pRGBArray;
help: TBitmap;
begin
help := TBitmap.Create;
help.Width := Bitmap.Width;
help.Height := Bitmap.Height;
help.PixelFormat := Bitmap.PixelFormat; <{only pf24bit for now}
for j := 0 to Bitmap.Height - 1 do
begin
rowIn := Bitmap.ScanLine[j];
rowOut := help.ScanLine[Bitmap.Height - j - 1];
for i := 0 to Bitmap.Width - 1 do
rowOut[Bitmap.Width - i - 1] := rowIn[i]
end;
bitmap.assign(help);
help.free;
end;

end.


 
Skier   (2002-08-27 13:06) [4]

>[BAD]Angel

> А точнее? ;-)

1) Заводишь IE
2) Набираешь URL
3) Дальше я думаю ясно...


 
murza   (2002-08-27 13:06) [5]

По этим формулам вычисляются координаты поворота точки (x1,y1) на угол angle
x2 = x1*cos(angle) - y1*sin(angle)
y2 = x1*sin(angle) + y1*cos(angle)
(Может че со знаками напутал)
ЗЫ вычисление косинусов и синусов вынести! Чтоб одинраз вычислялись.


 
MBo   (2002-08-27 13:09) [6]

function BmpRot(const B: TBitmap;fi:integer):TBitmap;
type
TRGBTripleArray = array[word] of TRGBTriple;
pRGBTripleArray = ^TRGBTripleArray;
var
x0,y0,i,j,x1,y1,x11,y11,x2,y2:integer;
ht,wd,newht,newwd:integer;
cfi,sfi: double;
sline1,sline2: pRGBTRipleArray;
BEGIN
sfi:=sin(degtorad(fi));
cfi:=cos(degtorad(fi));
ht:=b.height;
wd:=b.width;
newwd:=abs(round(ht*sfi))+abs(round(wd*cfi));
newht:=abs(round(wd*sfi))+abs(round(ht*cfi));
Result:=TBitmap.create;
Result.Width:=newwd;
Result.Height:=newht;
Result.PixelFormat:=pf24bit;
x0:=wd div 2;
y0:=ht div 2;
for j :=newht-1 downto 0 do begin
sline2 := Result.scanline[j];
y1:= 2*(j-(newht-ht) div 2 -y0);
for i := newwd-1 downto 0 do begin
x1:=2*(i-(newwd-wd) div 2 -x0);
x2 :=round(x1 * cfi - y1 * sfi);
y2 :=round(x1 * sfi + y1 * cfi);
x11:=x2 div 2 +x0;
y11:=y2 div 2 +y0;
if (x11>=0)and(x11<wd)and(y11>=0)and(y11<ht) then begin
sline1 := b.scanline[y11];
sline2[i] := sline1[x11];
end;
end;
end;
end;



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.09.05;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.007 c
1-14166
-=M-A-K-C=-
2002-08-24 22:42
2002.09.05
Как в мою прогу, неиспользующую Form, зусунуть HotKey


14-14233
Chesterfield
2002-08-08 21:39
2002.09.05
славный TEAC (Куда ни кинь - везде клин.)


1-14055
Schummi
2002-08-26 09:46
2002.09.05
MessageDlgEx


4-14331
SDv-503
2002-07-01 00:48
2002.09.05
Как программно нажать на клавишу в другом приложении ?


3-13915
nic418
2002-08-15 10:32
2002.09.05
Help! Создание сложного индекса для .DBF - файла с BDE





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский