Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > Графика и игры
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
  #5  
Старый 25.06.2009, 13:30
Rat Rat вне форума
Активный
 
Регистрация: 12.09.2008
Сообщения: 391
Репутация: 6078
По умолчанию

Делаю так:

Код:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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."

Если я коментирую строки:
Код:
1
2
If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit])
then raise exception.create ('Error, bitmap format not supported.') ;

То далее выдается ошибка: 'Scan line index out of range'.

Что не так?
 


Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 18:11.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025