Kamis, 17 Juni 2010
GRAFIKA KOMPUTER & VISUALISASI
Nama : Wiwi Siti Robiah Adawiah
NIM : 208700957
Kelas : IF E
Hasil Pengamatan:
Program ini merupakan program untuk menampilkan image yang bertype bmp,ico,wmf dan emf.
Pertama kali Program dijalankan (Eksekusi) akan muncul kotak dialog sebagai berikut :
(Error in module Unit 1: Declaration of class TForm1 is missing or incorrect.)
Setelah saya amati, ada beberapa kesalahan yang saya temukan pada program ini, yaitu program image view diantaranya seperti :
1. Dalam uses ditambahkan Dialog
2. Penulisan if FileExt = '.ICO' then Icon := Image1.Picture.Icon;
seharusnya :
begin
Icon:= Image1.Picture.Icon
ViewForm.Image1.Picture.Icon:=Icon;
3. UpDown1.Enabled := True;
UpDownEdit.Enabled := True;
Label2.Enabled := True;
Seharusnya :
end;
UpDown1.Enabled := GlyphCheck.Checked;
UpDownEdit.Enabled := GlyphCheck.Checked;
Label2.Enabled := GlyphCheck.Checked;
dan menghapus ‘end’ pada program ini
4.Menambahkan :
resourcestring
sMinValue = ‘Value below minimum’;
sMaxValue= ‘Value over maximum’;
UpDownEdit.Text :=’1’;
raise ErangeError.Create(sMinValue);
end;
else if (StrToInt(UpDownEdit.Text) > UpDown1.Max) then
begin
UpDownEdit.Text := '4';
raise ERangeError.Create(sMaxValue);
end;
Pada procedure TImageForm.ViewBtnClick(Sender: TObject);
dan
UpDown1.Min := 1; UpDown1.Max := 4; pada procedure TImageForm.FormCreate(Sender: TObject);
Dibawah ini merupakan program yang telah saya Koreksi dengan hasil yang memuaskan :
unit ImageWin;
interface
uses Windows, Classes, Graphics, Forms, Controls,
FileCtrl, StdCtrls, ExtCtrls, Buttons, Spin, ComCtrls, Dialogs;
type
TImageForm = class(TForm)
DirectoryListBox1: TDirectoryListBox;
DriveComboBox1: TDriveComboBox;
FileEdit: TEdit;
UpDownGroup: TGroupBox;
SpeedButton1: TSpeedButton;
BitBtn1: TBitBtn;
DisabledGrp: TGroupBox;
SpeedButton2: TSpeedButton;
BitBtn2: TBitBtn;
Panel1: TPanel;
Image1: TImage;
FileListBox1: TFileListBox;
Label2: TLabel;
ViewBtn: TBitBtn;
Bevel1: TBevel;
Bevel2: TBevel;
FilterComboBox1: TFilterComboBox;
GlyphCheck: TCheckBox;
StretchCheck: TCheckBox;
UpDownEdit: TEdit;
UpDown1: TUpDown;
procedure FileListBox1Click(Sender: TObject);
procedure ViewBtnClick(Sender: TObject);
procedure ViewAsGlyph(const FileExt: string);
procedure GlyphCheckClick(Sender: TObject);
procedure StretchCheckClick(Sender: TObject);
procedure FileEditKeyPress(Sender: TObject; var Key: Char);
procedure UpDownEditChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FormCaption: string;
end;
var
ImageForm: TImageForm;
implementation
uses ViewWin, SysUtils;
{$R *.dfm}
procedure TImageForm.FileListBox1Click(Sender: TObject);
var
FileExt: string[4];
begin
FileExt := AnsiUpperCase(ExtractFileExt(FileListBox1.Filename));
if (FileExt = '.BMP') or (FileExt = '.ICO') or (FileExt = '.WMF') or
(FileExt = '.EMF') then
begin
Image1.Picture.LoadFromFile(FileListBox1.Filename);
Caption := FormCaption + ExtractFilename(FileListBox1.Filename);
if (FileExt = '.BMP') then
begin
Caption := Caption +
Format(' (%d x %d)', [Image1.Picture.Width, Image1.Picture.Height]);
ViewForm.Image1.Picture := Image1.Picture;
ViewForm.Caption := Caption;
if GlyphCheck.Checked then ViewAsGlyph(FileExt);
end
else
GlyphCheck.Checked := False;
if FileExt = '.ICO' then Icon := Image1.Picture.Icon;
begin
Icon:= Image1.Picture.Icon
ViewForm.Image1.Picture.Icon:=Icon;
end;
if (FileExt = '.WMF') or (FileExt = '.EMF') then
ViewForm.Image1.Picture.Metafile := Image1.Picture.Metafile;
end;
end;
procedure TImageForm.GlyphCheckClick(Sender: TObject);
begin
ViewAsGlyph(AnsiUpperCase(ExtractFileExt(FileListBox1.Filename)));
end;
procedure TImageForm.ViewAsGlyph(const FileExt: string);
begin
if GlyphCheck.Checked and (FileExt = '.BMP') then
begin
SpeedButton1.Glyph := Image1.Picture.Bitmap;
SpeedButton2.Glyph := Image1.Picture.Bitmap;
UpDown1.Position := SpeedButton1.NumGlyphs;
BitBtn1.Glyph := Image1.Picture.Bitmap;
BitBtn2.Glyph := Image1.Picture.Bitmap;
UpDown1.Enabled := True;
UpDownEdit.Enabled := True;
Label2.Enabled := True;
end
else begin
SpeedButton1.Glyph := nil;
SpeedButton2.Glyph := nil;
BitBtn1.Glyph := nil;
BitBtn2.Glyph := nil;
end;
UpDown1.Enabled := GlyphCheck.Checked;
UpDownEdit.Enabled := GlyphCheck.Checked;
Label2.Enabled := GlyphCheck.Checked;
end;
end;
procedure TImageForm.ViewBtnClick(Sender: TObject);
begin
ViewForm.HorzScrollBar.Range := Image1.Picture.Width;
ViewForm.VertScrollBar.Range := Image1.Picture.Height;
ViewForm.Caption := Caption;
ViewForm.Show;
ViewForm.WindowState := wsNormal;
end;
procedure TImageForm.UpDownEditChange(Sender: TObject);
resourcestring
sMinValue = ‘Value below minimum’;
sMaxValue= ‘Value over maximum’;
begin
if (StrToInt (UpDownEdit.Text) <> UpDown1.Max) then
begin
UpDownEdit.Text := '4';
raise ERangeError.Create(sMaxValue);
end;
SpeedButton1.NumGlyphs := UpDown1.Position;
SpeedButton2.NumGlyphs := UpDown1.Position;
end;
procedure TImageForm.StretchCheckClick(Sender: TObject);
begin
Image1.Stretch := StretchCheck.Checked;
end;
procedure TImageForm.FileEditKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
FileListBox1.ApplyFilePath(FileEdit.Text);
Key := #0;
end;
end;
procedure TImageForm.FormCreate(Sender: TObject);
begin
FormCaption := Caption + ' - ';
UpDown1.Min := 1;
UpDown1.Max := 4;
end;
end.
terimakasih.....
Diposting oleh
wistie