1 { KOL MCK } // Do not remove this line!
8 //{$DEFINE TEST_JPGPROGRESS}
11 uses Windows
, Messages
, ShellAPI
, KOL
{$IFNDEF KOL_MCK}, mirror
, Classes
,
12 mckCtrls
, Controls
{$ENDIF} {$IFNDEF BMPONLY}, JpegObj
{$ENDIF};
15 Windows
, Messages
, SysUtils
, Classes
, Graphics
, Controls
, Forms
, Dialogs
;
20 {$I MCKfakeClasses.inc}
27 KOLProject1
: TKOLProject
;
29 PaintBox1
: TKOLPaintBox
;
30 ListBox1
: TKOLListBox
;
33 procedure KOLForm1FormCreate(Sender
: PObj
);
34 procedure ListBox1SelChange(Sender
: PObj
);
35 procedure KOLForm1Destroy(Sender
: PObj
);
36 procedure PaintBox1Paint(Sender
: PControl
; DC
: HDC
);
38 { Private declarations }
40 { Public declarations }
41 JPG
: {$IFDEF BMPONLY} PBitmap
; {$ELSE} PJpeg
; {$ENDIF}
43 procedure JpegProgress( Sender
: PJpeg
; const R
: TRect
; var Stop
: Boolean );
48 Form1
{$IFDEF KOL_MCK} : PForm1
{$ELSE} : TForm1
{$ENDIF} ;
51 procedure NewForm1( var Result
: PForm1
; AParent
: PControl
);
56 {$IFNDEF KOL_MCK} {$R *.DFM} {$ENDIF}
62 procedure TForm1
.KOLForm1FormCreate(Sender
: PObj
);
65 ListBox1
.AddDirList( GetStartDir
+ '*.bmp', FILE_ATTRIBUTE_NORMAL
);
67 ListBox1
.AddDirList( GetStartDir
+ '*.jp*', FILE_ATTRIBUTE_NORMAL
);
71 procedure TForm1
.ListBox1SelChange(Sender
: PObj
);
74 S
:= ListBox1
.Items
[ ListBox1
.CurIndex
];
75 if FileExists( S
) then
79 JPG
:= NewBitmap(0,0);
80 JPG
.LoadFromFile( S
);
81 //JPG.PixelFormat := pf16bit;
84 {$IFDEF TEST_JPGPROGRESS}
85 JPG
.OnProgress
:= JpegProgress
;
86 PaintBox1
.Canvas
.FillRect( PaintBox1
.ClientRect
);
88 JPG
.LoadFromFile( S
);
91 //if not JPG.Empty then
96 procedure TForm1
.KOLForm1Destroy(Sender
: PObj
);
101 procedure TForm1
.PaintBox1Paint(Sender
: PControl
; DC
: HDC
);
103 if (JPG
<> nil) and not JPG
.Empty
then
105 JPG
.Draw( DC
, 0, 0 );
106 Sender
.Canvas
.FillRect( MakeRect( JPG
.Width
, 0, Sender
.ClientWidth
, Sender
.ClientHeight
) );
107 Sender
.Canvas
.FillRect( MakeRect( 0, JPG
.Height
, JPG
.Width
, Sender
.ClientHeight
) );
109 if Label1
.Caption
= '' then
110 if JPG
.Corrupted
then
111 Label1
.Caption
:= 'Corrupted';
115 Sender
.Canvas
.FillRect( Sender
.ClientRect
);
119 procedure TForm1
.JpegProgress(Sender
: PJpeg
; const R
: TRect
;
122 if not JPG
.Bitmap
.Empty
then
123 JPG
.Bitmap
.DIBDrawRect( PaintBox1
.Canvas
.Handle
, R
.Left
, R
.Top
, R
);
124 if JPG
.Corrupted
then
125 if Label1
.Caption
= '' then
126 Label1
.Caption
:= 'Corrupted';