Skip to content

Commit

Permalink
R38 ExportWidth/ExportHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroNick2020 committed Mar 17, 2022
1 parent 3e77c43 commit 83644f9
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 25 deletions.
8 changes: 4 additions & 4 deletions rmabout.lfm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
object AboutDialog: TAboutDialog
Left = -1185
Left = 464
Height = 313
Top = 131
Top = 236
Width = 600
BorderStyle = bsDialog
Caption = 'About'
ClientHeight = 313
ClientWidth = 600
ClientHeight = 0
ClientWidth = 0
DesignTimePPI = 120
LCLVersion = '2.0.10.0'
object ProgramNameLabel: TLabel
Expand Down
2 changes: 1 addition & 1 deletion rmabout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,lclintf;

Const
ProgramName ='Raster Master v1.0 Beta R37';
ProgramName ='Raster Master v1.0 Beta R38';
ProgramLicense = 'Released under MIT License';

type
Expand Down
4 changes: 2 additions & 2 deletions rmcolorvga.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object RMVgaColorDialog: TRMVgaColorDialog
Left = -760
Left = -1204
Height = 348
Top = 602
Top = 98
Width = 512
BorderStyle = bsDialog
Caption = 'VGA Color'
Expand Down
52 changes: 44 additions & 8 deletions rmexportprops.lfm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
object ImageExportForm: TImageExportForm
Left = 74
Height = 368
Top = 408
Width = 418
Left = 353
Height = 429
Top = 314
Width = 421
BorderStyle = bsDialog
Caption = 'Export Properties'
ClientHeight = 0
ClientWidth = 0
ClientHeight = 429
ClientWidth = 421
DesignTimePPI = 120
LCLVersion = '2.0.10.0'
object EditName: TEdit
Expand Down Expand Up @@ -80,11 +80,11 @@ object ImageExportForm: TImageExportForm
object Button1: TButton
Left = 304
Height = 31
Top = 312
Top = 360
Width = 94
Caption = 'OK'
OnClick = Button1Click
TabOrder = 5
TabOrder = 7
end
object CompilerType: TLabel
Left = 32
Expand All @@ -104,4 +104,40 @@ object ImageExportForm: TImageExportForm
Style = csDropDownList
TabOrder = 1
end
object EditWidth: TEdit
Left = 104
Height = 28
Top = 272
Width = 48
MaxLength = 3
NumbersOnly = True
TabOrder = 5
Text = '0'
end
object WidthLabel: TLabel
Left = 53
Height = 20
Top = 272
Width = 40
Caption = 'Width'
ParentColor = False
end
object EditHeight: TEdit
Left = 104
Height = 28
Top = 312
Width = 48
MaxLength = 3
NumbersOnly = True
TabOrder = 6
Text = '0'
end
object HeightLabel: TLabel
Left = 48
Height = 20
Top = 312
Width = 45
Caption = 'Height'
ParentColor = False
end
end
15 changes: 14 additions & 1 deletion rmexportprops.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
interface

uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,rmthumb,rwxgf2;
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, MaskEdit,
rmthumb, rwxgf2;

type

Expand All @@ -17,12 +18,16 @@ TImageExportForm = class(TForm)
ComboCompiler: TComboBox;
ComboMask: TComboBox;
ComboPalette: TComboBox;
EditWidth: TEdit;
EditHeight: TEdit;
EditName: TEdit;
imageName: TLabel;
ImageType: TLabel;
CompilerType: TLabel;
MaskType: TLabel;
PaletteType: TLabel;
WidthLabel: TLabel;
HeightLabel: TLabel;
ToggleBox1: TToggleBox;
procedure Button1Click(Sender: TObject);
procedure ComboCompilerChange(Sender: TObject);
Expand Down Expand Up @@ -280,6 +285,9 @@ procedure TImageExportForm.SetExportProps(props : ImageExportFormatRec);
ComboImage.ItemIndex:=EO.Image;
ComboMask.ItemIndex:=EO.mask;
ComboPalette.ItemIndex:=EO.Palette;
EditWidth.Text:=IntToStr(props.Width);
EditHeight.Text:=IntToStr(props.Height);

UpdateComboBoxes(ComboCompiler.ItemIndex);
end;

Expand All @@ -290,6 +298,9 @@ procedure TImageExportForm.GetExportProps(var props : ImageExportFormatRec);
props.Image:=ComboImage.ItemIndex;
props.mask:=ComboMask.ItemIndex;
props.Palette:=ComboPalette.ItemIndex;
props.Width:=StrToIntDef(EditWidth.Text,0);
props.Height:=StrToIntDef(EditHeight.Text,0);

end;

procedure TImageExportForm.InitComboBoxes;
Expand Down Expand Up @@ -329,6 +340,8 @@ procedure TImageExportForm.InitComboBoxes;
ComboPalette.Items.Add('AmigaBASIC -4 Bit');

ComboPalette.ItemIndex:=0;
EditWidth.Text:='0';
EditHeight.Text:='0';
end;

end.
Expand Down
42 changes: 39 additions & 3 deletions rmthumb.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Image : integer; // user - 0 = do not export, Image Format, 1 = PutImage format for most compiler
Mask : integer; // user - 0 = do not export, 1 = Inverse mode - all black become white, all other colors become black
Palette : integer; // user - 0 = do not export, 1 = EGA Index, 2 VGA, 3 Amiga RGB - will determine from palette mode in RM
Width : integer; // width overwrite - if not 0 use this value as width
Height : integer; // height overwrite - if not 0 use this value as height
end;

ImageThumbPropsRec = Packed Record
Expand Down Expand Up @@ -82,6 +84,9 @@
function GetWidth(index : integer) : integer;
function GetHeight(index : integer) : integer;

function GetExportWidth(index : integer) : integer;
function GetExportHeight(index : integer) : integer;

procedure MakeThumbImage(index : integer;var imglist : TImageList;action : integer);
procedure MakeThumbImageFromCore(index : integer;var imglist : TImageList;action : integer);

Expand Down Expand Up @@ -190,6 +195,9 @@ procedure TImageThumb.AddImage; //adds image to end of list
//copy the Export props from the first thum image
ImageMain[ImageCount-1].Props.ExportFormat:=ImageMain[0].Props.ExportFormat;
ImageMain[ImageCount-1].Props.ExportFormat.Name:='Image'+IntToStr(ImageCount);

// ImageMain[ImageCount-1].Props.ExportFormat.Width:=0;
// ImageMain[ImageCount-1].Props.ExportFormat.Height:=0;
end;
end;

Expand Down Expand Up @@ -338,6 +346,7 @@ procedure TImageThumb.SetColor(index : integer;colorIndex : integer; var cr : TR
ImageMain[index].Props.Palette[colorIndex].b:=cr.b;
end;


function TImageThumb.GetWidth(index : integer) : integer;
begin
GetWidth:=ImageMain[index].Props.Width;
Expand All @@ -348,6 +357,33 @@ function TImageThumb.GetHeight(index : integer) : integer;
GetHeight:=ImageMain[index].Props.Height;
end;


//if there is a custom width property (not 0) and less then props width
function TImageThumb.GetExportWidth(index : integer) : integer;
var
width : integer;
begin
Width:=ImageMain[index].Props.Width;
if (ImageMain[index].Props.ExportFormat.Width > 0) AND (ImageMain[index].Props.ExportFormat.Width < ImageMain[index].Props.Width) then
begin
Width:=ImageMain[index].Props.ExportFormat.Width;
end;
GetExportWidth:=Width;
end;

//if there is a custom height property (not 0) and less then props height
function TImageThumb.GetExportHeight(index : integer) : integer;
var
height : integer;
begin
Height:=ImageMain[index].Props.Height;
if (ImageMain[index].Props.ExportFormat.Height > 0) AND (ImageMain[index].Props.ExportFormat.Height < ImageMain[index].Props.Height) then
begin
Height:=ImageMain[index].Props.ExportFormat.Height;
end;
GetExportHeight:=Height;
end;

procedure TImageThumb.GetExportOptions(index : integer;var EO : ImageExportFormatRec);
begin
EO:=ImageMain[index].Props.ExportFormat;
Expand Down Expand Up @@ -469,7 +505,7 @@ procedure TImageThumb.OpenProject(filename : string;insertmode : boolean);
Blockread(F,head,sizeof(head));
{$I+}
if IORESULT <>0 then exit;
if (head.sig='RMP') and (head.version=1) then
if (head.sig='RMP') and (head.version=2) then
begin
//delete all current images - use should be warn when oopening files
count:=head.ImageCount;
Expand Down Expand Up @@ -508,8 +544,8 @@ procedure TImageThumb.SaveProject(filename : string);
count:=GetCount;

head.ImageCount:=count;
head.SIG:='RMP'; // Raster Master Project
head.version:=1;
head.SIG:='RMP'; // Raster Master Project
head.version:=2; // v2 introduced in R38 (added ExportWidth/ExportHieght), all previous up v37 were v1
Blockwrite(F,head,sizeof(head));
{$I+}
if IORESULT <>0 then exit;
Expand Down
12 changes: 6 additions & 6 deletions rres.pas
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ function GetRESPaletteSize(nColors,Lan,rgbFormat : integer) : longint;
count:=ImageThumbBase.GetCount;
for i:=0 to count-1 do
begin
width:=ImageThumbBase.GetWidth(i);
height:=ImageThumbBase.GetHeight(i);
width:=ImageThumbBase.GetExportWidth(i);
height:=ImageThumbBase.GetExportHeight(i);
ImageThumbBase.GetExportOptions(i,EO);
SetThumbIndex(i); //important - otherwise the GetMaxColor and GetPixel functions will not get the right data

Expand Down Expand Up @@ -376,8 +376,8 @@ function GetRESPaletteSize(nColors,Lan,rgbFormat : integer) : longint;
begin
ImageThumbBase.GetExportOptions(i,EO);

width:=ImageThumbBase.GetWidth(i);
height:=ImageThumbBase.GetHeight(i);
width:=ImageThumbBase.GetExportWidth(i);
height:=ImageThumbBase.GetExportHeight(i);
nColors:=ImageThumbBase.GetMaxColor(i)+1;
Size:=GetRESImageSize(width,height,nColors,EO.Lan,EO.Image);

Expand Down Expand Up @@ -454,8 +454,8 @@ function GetRESPaletteSize(nColors,Lan,rgbFormat : integer) : longint;
//convert and dump image
for i:=0 to count-1 do
begin
width:=ImageThumbBase.GetWidth(i);
height:=ImageThumbBase.GetHeight(i);
width:=ImageThumbBase.GetExportWidth(i);
height:=ImageThumbBase.GetExportHeight(i);
ImageThumbBase.GetExportOptions(i,EO);
SetThumbIndex(i); //important - otherwise the GetMaxColor and GetPixel functions will not get the right data

Expand Down

0 comments on commit 83644f9

Please sign in to comment.