Browse Source

Completed FormatUIContainer ifBmp

Completed FormatUIContainer ifBmp
Massimo Magnano 8 months ago
parent
commit
6f7fc70635
2 changed files with 22 additions and 14 deletions
  1. 1 0
      bgraformatui.lfm
  2. 21 14
      bgraformatui.pas

+ 1 - 0
bgraformatui.lfm

@@ -405,6 +405,7 @@ object BGRAFormatUIContainer: TBGRAFormatUIContainer
       ReadOnly = True
       Style = csDropDownList
       TabOrder = 1
+      OnChange = ifBmp_BitsPerPixelChange
     end
     object Label7: TLabel
       Left = 16

+ 21 - 14
bgraformatui.pas

@@ -79,6 +79,7 @@ type
     panelButtons: TPanel;
     ifJpeg_ProgressiveEncoding: TCheckBox;
     procedure FormCreate(Sender: TObject);
+    procedure ifBmp_BitsPerPixelChange(Sender: TObject);
     procedure ifBmp_GrayScaleChange(Sender: TObject);
   private
     curFormat: TBGRAImageFormat;
@@ -263,6 +264,8 @@ end;
 function TBGRAFormatUIContainer.GetControlValue(var AValue: TValue; const AControl: TControl): Boolean;
 begin
   Result:= False;
+
+  if AControl.Enabled then
   try
      //Types will be added as we use them,
      //it is the responsibility of the UI creator not to put in crap like
@@ -404,6 +407,19 @@ begin
   end;
 end;
 
+procedure TBGRAFormatUIContainer.FormCreate(Sender: TObject);
+var
+   i: Integer;
+
+begin
+  //Bitmap Format
+  oldBmp_BitsPerPixel:= -1;
+
+  //Fill Bits x Pixels Objects Values
+  for i:=0 to ifBmp_BitsPerPixel.Items.Count-1 do
+    ifBmp_BitsPerPixel.Items.Objects[i]:= TObject(PtrUInt(BMP_BitsValidValues[i]));
+end;
+
 procedure TBGRAFormatUIContainer.ifBmp_GrayScaleChange(Sender: TObject);
 begin
   if ifBmp_GrayScale.Checked
@@ -411,26 +427,17 @@ begin
          oldBmp_BitsPerPixel:= ifBmp_BitsPerPixel.ItemIndex;
          ifBmp_BitsPerPixel.ItemIndex:= 2; //GrayScale
        end
-  else begin
-         if (oldBmp_BitsPerPixel > -1) then ifBmp_BitsPerPixel.ItemIndex:= oldBmp_BitsPerPixel;
-       end;
+  else if (oldBmp_BitsPerPixel > -1)
+       then ifBmp_BitsPerPixel.ItemIndex:= oldBmp_BitsPerPixel;
 
   ifBmp_RLECompress.Enabled:= ifBmp_GrayScale.Checked;
   ifBmp_BitsPerPixel.Enabled:= not(ifBmp_GrayScale.Checked);
 end;
 
-procedure TBGRAFormatUIContainer.FormCreate(Sender: TObject);
-var
-   i: Integer;
-
+procedure TBGRAFormatUIContainer.ifBmp_BitsPerPixelChange(Sender: TObject);
 begin
-  //Bitmap Format
-  oldBmp_BitsPerPixel:= -1;
-
-  //TO-DO: Does not works test better tomorrow
-  //Fill Bits x Pixels Objects Values
-  for i:=0 to ifBmp_BitsPerPixel.Items.Count-1 do
-    ifBmp_BitsPerPixel.Items.Objects[i]:= TObject(PtrUInt(BMP_BitsValidValues[i]));
+  ifBmp_RLECompress.Enabled:= (ifBmp_BitsPerPixel.ItemIndex in [1,2]);
+  ifBmp_GrayScale.Enabled:= (ifBmp_BitsPerPixel.ItemIndex = 2);
 end;
 
 function TBGRAFormatUIContainer.AdjustPanels: Boolean;