Browse Source

fixed a color inversion bug on Android.

* fixed path issue in FMX Demo
Ugochukwu Mmaduekwe 7 years ago
parent
commit
f7aabfefce

+ 8 - 5
QRCodeGenLib.Demo/src/uQrCodeGeneratorDemoFMX.pas

@@ -4,6 +4,7 @@ interface
 
 
 uses
 uses
   SysUtils,
   SysUtils,
+  IOUtils,
   UITypes,
   UITypes,
   FMX.Dialogs,
   FMX.Dialogs,
   FMX.Graphics,
   FMX.Graphics,
@@ -269,10 +270,8 @@ var
   LFilePath: String;
   LFilePath: String;
   LBitmap: TBitmap;
   LBitmap: TBitmap;
 begin
 begin
-  LFilePath := ExtractFilePath(ParamStr(0));
-  LFilePath := IncludeTrailingPathDelimiter(LFilePath);
-  LFilePath := IncludeTrailingPathDelimiter(LFilePath) + FolderName;
-  LFilePath := IncludeTrailingPathDelimiter(LFilePath);
+
+  LFilePath := TPath.Combine(TPath.GetSharedDocumentsPath, FolderName);
 
 
   if not DirectoryExists(LFilePath) then
   if not DirectoryExists(LFilePath) then
   begin
   begin
@@ -283,13 +282,17 @@ begin
       Exit;
       Exit;
     end;
     end;
   end;
   end;
-  LFilePath := LFilePath + AFileName;
+
+  LFilePath := TPath.Combine(LFilePath, AFileName);
   // create bmp
   // create bmp
   LBitmap := AQrCode.ToBmpImage(AScale, ABorder);
   LBitmap := AQrCode.ToBmpImage(AScale, ABorder);
   try
   try
     try
     try
+{$IF DEFINED(MSWINDOWS) OR DEFINED(MACOS)}
+      // bmp is only supported on Windows and MACOS
       // save bmp
       // save bmp
       LBitmap.SaveToFile(LFilePath + '.bmp');
       LBitmap.SaveToFile(LFilePath + '.bmp');
+{$ENDIF}
       // save jpeg
       // save jpeg
       LBitmap.SaveToFile(LFilePath + '.jpg');
       LBitmap.SaveToFile(LFilePath + '.jpg');
       // save png
       // save png

+ 1 - 6
QRCodeGenLib/src/QRCodeGen/QlpQrCode.pas

@@ -14,7 +14,6 @@ uses
   Vcl.Imaging.pngimage, // for VCL PNG Support
   Vcl.Imaging.pngimage, // for VCL PNG Support
 {$ELSEIF DEFINED(FMX)}
 {$ELSEIF DEFINED(FMX)}
   FMX.Graphics,
   FMX.Graphics,
-  FMX.Utils,
   UIConsts,
   UIConsts,
   UITypes,
   UITypes,
 {$ELSEIF DEFINED(LCL)}
 {$ELSEIF DEFINED(LCL)}
@@ -1148,7 +1147,6 @@ var
   LDoColor: Boolean;
   LDoColor: Boolean;
   LBrushColor: TColor;
   LBrushColor: TColor;
   LForegroundColor, LBackgroundColor: TColor;
   LForegroundColor, LBackgroundColor: TColor;
-  LScanLine: PAlphaColorArray;
   LBitData: TBitmapData;
   LBitData: TBitmapData;
 begin
 begin
   Result := TBitmap.Create;
   Result := TBitmap.Create;
@@ -1162,7 +1160,6 @@ begin
     try
     try
       for LColumn := 0 to System.Pred(Result.Height) do
       for LColumn := 0 to System.Pred(Result.Height) do
       begin
       begin
-        LScanLine := LBitData.GetScanLine(LColumn);
         for LRow := 0 to System.Pred(Result.Width) do
         for LRow := 0 to System.Pred(Result.Width) do
         begin
         begin
           LDoColor := GetModule((LRow div AScale) - ABorder,
           LDoColor := GetModule((LRow div AScale) - ABorder,
@@ -1175,9 +1172,7 @@ begin
           begin
           begin
             LBrushColor := LBackgroundColor;
             LBrushColor := LBackgroundColor;
           end;
           end;
-          // Slow !!!
-          // LBitData.SetPixel(LRow, LColumn, LBrushColor);
-          LScanLine^[LRow] := LBrushColor;
+          LBitData.SetPixel(LRow, LColumn, LBrushColor);
         end;
         end;
 
 
       end;
       end;