summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/ptc/tests/view.pp
blob: 657239dc28a09df05916aa9aedce343aab2dd160 (plain)
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
{$MODE objfpc}

uses
  SysUtils, ptc;

{$I endian.inc}

var
  console: IPTCConsole;
  surface: IPTCSurface;
  format: IPTCFormat;
  pixels: PUint8;
  I: Integer;
  F: File;
begin
  try
    try
      console := TPTCConsoleFactory.CreateNew;

      {$IFDEF FPC_LITTLE_ENDIAN}
      format := TPTCFormatFactory.CreateNew(24, $00FF0000, $0000FF00, $000000FF);
      {$ELSE FPC_LITTLE_ENDIAN}
      format := TPTCFormatFactory.CreateNew(24, $000000FF, $0000FF00, $00FF0000);
      {$ENDIF FPC_LITTLE_ENDIAN}
      surface := TPTCSurfaceFactory.CreateNew(320, 200, format);

      console.open('test', surface.width, surface.height, format);

      for I := 1 to 100 do
      begin
        Writeln('test', I, '.raw');
        AssignFile(F, 'test' + IntToStr(I) + '.raw');
        Reset(F, 1);
        try
          pixels := surface.lock;
          try
            BlockRead(F, pixels^, surface.height * surface.pitch);
          finally
            surface.unlock;
          end;
        finally
          CloseFile(F);
        end;
        surface.copy(console);
        console.update;
        console.ReadKey;
      end;
    finally
      if Assigned(console) then
        console.close;
    end;
  except
    on error: TPTCError do
      { report error }
      error.report;
  end;
end.