![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Загружаю в TImage - jpeg.
Как сделать для него FadeIn и FadeOut ? |
#2
|
||||
|
||||
![]() Цитата:
|
#3
|
|||
|
|||
![]() В исходниках видел. Вот оно. Но эта вещь работает только с BMP. А мне нужно именно JPEG.
Аналогичный код: Код:
procedure FadeOut(const BMP:TImage; Pause:integer) ; var BytesPorScan : integer; w,h : integer; p : pByteArray; counter : integer; begin {This only works with 24 or 32 bits bitmaps} If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit]) then raise exception.create ('Error, bitmap format not supported.') ; try BytesPorScan:= Abs(Integer(BMP.Picture.Bitmap.ScanLine[1])- Integer(BMP.Picture.Bitmap.ScanLine[0])) ; except raise exception.create('Error') ; end; {Decrease the RGB for each single pixel} for counter:=1 to 256 do begin for h:=0 to BMP.Picture.Bitmap.Height-1 do begin P:=BMP.Picture.Bitmap.ScanLine[h]; for w:=0 to BytesPorScan-1 do if P^[w] >0 then P^[w]:=P^[w]-1; end; Sleep(Pause) ; BMP.Refresh; end; end; {procedure FadeOut} Последний раз редактировалось Rat, 25.06.2009 в 11:03. |
#4
|
||||
|
||||
![]() Цитата:
ПС. На сайт добавлен новый раздел Delphi Programming Guide: http://www.delphisources.ru/pages/fa...i-7/index.html Последний раз редактировалось Admin, 06.11.2010 в 14:20. |
#5
|
|||
|
|||
![]() Делаю так:
Код:
unit MainUnit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Jpeg, ComCtrls; type TForm1 = class(TForm) Button1: TButton; OpenDialog1: TOpenDialog; Image1: TImage; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private procedure FadeOut(const BMP: TImage; Pause: integer); { Private declarations } public { Public declarations } end; var Form1: TForm1; jpeg: TJPEGImage; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if OpenDialog1.Execute then begin jpeg.LoadFromFile(OpenDialog1.FileName); Image1.Picture.Assign(jpeg); end; end; procedure TForm1.FormCreate(Sender: TObject); begin jpeg := TJPEGImage.Create; jpeg.CompressionQuality := 100; end; procedure TForm1.Button2Click(Sender: TObject); begin FadeOut(Image1, 10); end; procedure TForm1.FadeOut(const BMP:TImage; Pause:integer) ; var BytesPorScan : integer; w,h : integer; p : pByteArray; counter : integer; begin {This only works with 24 or 32 bits bitmaps} If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit]) then raise exception.create ('Error, bitmap format not supported.') ; try BytesPorScan:= Abs(Integer(BMP.Picture.Bitmap.ScanLine[1])- Integer(BMP.Picture.Bitmap.ScanLine[0])) ; except raise exception.create('Error') ; end; {Decrease the RGB for each single pixel} for counter:=1 to 256 do begin for h:=0 to BMP.Picture.Bitmap.Height-1 do begin P:=BMP.Picture.Bitmap.ScanLine[h]; for w:=0 to BytesPorScan-1 do if P^[w] >0 then P^[w]:=P^[w]-1; end; Sleep(Pause) ; BMP.Refresh; end; end; {procedure FadeOut} end. В TImage1 загружается jpg. Вроде как конвертируется в bmp. При нажатии на button2 выдается ошибка "Error, bitmap format not supported." Если я коментирую строки: Код:
If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit]) then raise exception.create ('Error, bitmap format not supported.') ; То далее выдается ошибка: 'Scan line index out of range'. Что не так? |