Bitmap conversion now operational

This commit is contained in:
Raymond 2010-05-11 20:52:17 +02:00
parent 229cdd6886
commit 12cb2c1513
3 changed files with 99 additions and 22 deletions

View File

@ -3,36 +3,65 @@ object BitmapConvForm: TBitmapConvForm
Height = 240
Top = 192
Width = 320
Caption = 'BitmapConvForm'
Caption = 'Bitmap conversion'
ClientHeight = 240
ClientWidth = 320
Constraints.MinHeight = 240
Constraints.MinWidth = 320
LCLVersion = '0.9.29'
object Button1: TButton
object ToStringButton: TButton
Left = 192
Height = 36
Top = 184
Width = 113
Caption = 'Button1'
Anchors = [akRight, akBottom]
Caption = 'To string'
OnClick = ToStringButtonClick
TabOrder = 0
end
object CheckBox1: TCheckBox
Left = 224
object PadOutput: TCheckBox
Left = 192
Height = 17
Top = 152
Top = 160
Width = 71
Caption = 'CheckBox1'
Anchors = [akRight, akBottom]
Caption = 'Pad output'
Checked = True
State = cbChecked
TabOrder = 1
end
object Button2: TButton
object OpenButton: TButton
Left = 12
Height = 36
Top = 184
Width = 90
Anchors = [akRight, akBottom]
Caption = 'Open'
OnClick = Button2Click
OnClick = OpenButtonClick
TabOrder = 2
end
object OpenPictureDialog1: TOpenPictureDialog
object GroupBox: TGroupBox
Left = 12
Height = 145
Top = 8
Width = 284
Anchors = [akTop, akLeft, akRight, akBottom]
Caption = 'Image'
ClientHeight = 127
ClientWidth = 280
TabOrder = 3
object ImagePreview: TImage
Left = 0
Height = 127
Top = 0
Width = 280
Align = alClient
Center = True
end
end
object OpenPictureDialog: TOpenPictureDialog
FilterIndex = 2
Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]
left = 128
top = 184
end

View File

@ -5,22 +5,26 @@ unit bitmapconv;
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, EditBtn, ExtDlgs;
Classes, SysUtils, FileUtil, bitmaps, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, EditBtn, ExtDlgs, ExtCtrls;
type
{ TBitmapConvForm }
TBitmapConvForm = class(TForm)
Button1: TButton;
Button2: TButton;
CheckBox1: TCheckBox;
OpenPictureDialog1: TOpenPictureDialog;
procedure Button2Click(Sender: TObject);
GroupBox: TGroupBox;
ToStringButton: TButton;
OpenButton: TButton;
PadOutput: TCheckBox;
ImagePreview: TImage;
OpenPictureDialog: TOpenPictureDialog;
procedure OpenButtonClick(Sender: TObject);
procedure ToStringButtonClick(Sender: TObject);
private
{ private declarations }
public
dispPic : TMufasaBitmap;
{ public declarations }
end;
@ -28,15 +32,59 @@ var
BitmapConvForm: TBitmapConvForm;
implementation
uses
SimbaUnit;
const
BmpSizeTxt = '(%dx%d)';
{$R *.lfm}
{ TBitmapConvForm }
procedure TBitmapConvForm.Button2Click(Sender: TObject);
procedure TBitmapConvForm.OpenButtonClick(Sender: TObject);
var
x : TMufasaBitmap;
begin
if OpenPictureDialog1.Execute then
writeln(OpenPictureDialog1.FileName);
if OpenPictureDialog.Execute then
begin
try
ImagePreview.Picture.LoadFromFile(OpenPictureDialog.FileName);
GroupBox.Caption:= Format(BmpSizeTxt,[ImagePreview.Picture.Width,ImagePreview.Picture.Height]);
x := TMufasaBitmap.Create;
x.LoadFromFile(OpenPictureDialog.FileName);
if dispPic <> nil then
dispPic.Free;
dispPic := x;
except
formWritelnEx('ERROR loading the file: ' + OpenPictureDialog.FileName);
ImagePreview.Picture := nil;
if dispPic <> nil then
FreeAndNil(dispPic);
end;
end;
end;
procedure TBitmapConvForm.ToStringButtonClick(Sender: TObject);
var
str : string;
strend : string;
len : integer;
begin
if dispPic <> nil then
begin
str := ' Bmp := BitmapFromString('+
inttostr(disppic.Width)+ ', ' + inttostr(disppic.height) +', '#39 + dispPic.ToString;
strend := #39 +');';
len := length(str);
if PadOutput.Checked then
while Len > 65 do
begin
formWritelnEx(Copy(str,1,62) + #39 + ' +');
delete(str,1,62);
str := StringOfChar(' ',8) + #39 + str;
len := length(str);
end;
formWritelnEx(str + strend);
end;
end;
end.

View File

@ -1349,7 +1349,7 @@ object SimbaForm: TSimbaForm
OnClick = MenuItemSettingsButtonClick
end
object MenuItemBitmapConv: TMenuItem
Caption = 'New Item50'
Caption = '&Bitmap conversion'
OnClick = MenuItemBitmapConvClick
end
object MenuItemDivider10: TMenuItem