View Issue Details

IDProjectCategoryView StatusLast Update
0034388FPCFCLpublic2018-10-18 15:47
ReporterOndrej PokornyAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034388: FPImage: HtmlToFPColor doesn't set the second byte, which results in corrupt color
DescriptionHtmlToFPColor doesn't set the second byte of FPColor component (which is WORD).

This results in a corrupt color.
Steps To ReproduceThe following program creates a simple 100x100px JPEG that should be all white. It is black instead:

program FPImgHTML;

uses
  FPImage, FPWriteJPEG, FPImgCanv, FPCanvas;

var
  xNew: TFPCustomImage;
  xCanvas: TFPImageCanvas;
  xNewWidth, xNewHeight: Integer;
begin
  xNew := nil;
  xCanvas := nil;
  try
    xNewWidth := 100;
    xNewHeight := 100;

    xNew := TFPMemoryImage.Create(xNewWidth, xNewHeight);
    xCanvas := TFPImageCanvas.Create(xNew);

    xCanvas.Pen.Style := psClear;
    xCanvas.Brush.FPColor := HtmlToFPColor('#FFFFFF');
    xCanvas.FillRect(0, 0, xNewWidth, xNewHeight);

    xNew.SaveToFile('test.jpg');
  finally
    xCanvas.Free;
    xNew.Free;
  end;
end.
Additional InformationPatch attached.
TagsNo tags attached.
Fixed in Revision39973
FPCOldBugId
FPCTarget
Attached Files
  • HtmlToFPColor-01.patch (427 bytes)
    Index: packages/fcl-image/src/fpimage.pp
    ===================================================================
    --- packages/fcl-image/src/fpimage.pp	(revision 39854)
    +++ packages/fcl-image/src/fpimage.pp	(working copy)
    @@ -721,7 +721,10 @@
       begin
         Val('$'+Hex, W, Code);
         Result := (Code = 0);
    -    if not Result then W := 0;
    +    if not Result then
    +      W := 0
    +    else
    +      W := W + W shl 8;
       end;
     
     var
    
  • HtmlToFPColor-02.patch (426 bytes)
    Index: packages/fcl-image/src/fpimage.pp
    ===================================================================
    --- packages/fcl-image/src/fpimage.pp	(revision 39854)
    +++ packages/fcl-image/src/fpimage.pp	(working copy)
    @@ -721,7 +721,10 @@
       begin
         Val('$'+Hex, W, Code);
         Result := (Code = 0);
    -    if not Result then W := 0;
    +    if Result then
    +      W := W or (W shl 8)
    +    else
    +      W := 0;
       end;
     
     var
    

Activities

Ondrej Pokorny

2018-10-04 22:51

developer  

HtmlToFPColor-01.patch (427 bytes)
Index: packages/fcl-image/src/fpimage.pp
===================================================================
--- packages/fcl-image/src/fpimage.pp	(revision 39854)
+++ packages/fcl-image/src/fpimage.pp	(working copy)
@@ -721,7 +721,10 @@
   begin
     Val('$'+Hex, W, Code);
     Result := (Code = 0);
-    if not Result then W := 0;
+    if not Result then
+      W := 0
+    else
+      W := W + W shl 8;
   end;
 
 var

Ondrej Pokorny

2018-10-04 22:57

developer  

HtmlToFPColor-02.patch (426 bytes)
Index: packages/fcl-image/src/fpimage.pp
===================================================================
--- packages/fcl-image/src/fpimage.pp	(revision 39854)
+++ packages/fcl-image/src/fpimage.pp	(working copy)
@@ -721,7 +721,10 @@
   begin
     Val('$'+Hex, W, Code);
     Result := (Code = 0);
-    if not Result then W := 0;
+    if Result then
+      W := W or (W shl 8)
+    else
+      W := 0;
   end;
 
 var

Ondrej Pokorny

2018-10-18 14:44

developer   ~0111450

Hi Michael, are there any problems with the patch?

Michael Van Canneyt

2018-10-18 15:26

administrator   ~0111451

Patience, I need time to download & check it :)

Applied, thank you very much !

Ondrej Pokorny

2018-10-18 15:47

developer   ~0111454

Thank you as well!

Issue History

Date Modified Username Field Change
2018-10-04 22:51 Ondrej Pokorny New Issue
2018-10-04 22:51 Ondrej Pokorny File Added: HtmlToFPColor-01.patch
2018-10-04 22:57 Ondrej Pokorny File Added: HtmlToFPColor-02.patch
2018-10-04 23:15 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-10-04 23:15 Michael Van Canneyt Status new => assigned
2018-10-18 14:44 Ondrej Pokorny Note Added: 0111450
2018-10-18 15:26 Michael Van Canneyt Fixed in Revision => 39973
2018-10-18 15:26 Michael Van Canneyt Note Added: 0111451
2018-10-18 15:26 Michael Van Canneyt Status assigned => resolved
2018-10-18 15:26 Michael Van Canneyt Fixed in Version => 3.3.1
2018-10-18 15:26 Michael Van Canneyt Resolution open => fixed
2018-10-18 15:26 Michael Van Canneyt Target Version => 3.2.0
2018-10-18 15:47 Ondrej Pokorny Note Added: 0111454
2018-10-18 15:47 Ondrej Pokorny Status resolved => closed