Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-01

TFPReaderXPM

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Colin Western

I have spotted a problem with TFPReaderXPM, in that it uses a case insensitive compare on the colour symbols. I think it needs the following:

diff -uNr fpc/fcl/image/fpreadxpm.pp fpc.w/fcl/image/fpreadxpm.pp
--- fpc/fcl/image/fpreadxpm.pp  2003-08-17 19:33:04.000000000 +0100
+++ fpc.w/fcl/image/fpreadxpm.pp        2004-01-17 11:54:32.000000000 +0000
@@ -268,8 +268,12 @@
        begin
        code := copy(s, p, cpp);
        inc(p,cpp);
-      color := Palette.indexof (code);
-      img.pixels[r-1,imgindex] := color;
+      for color := 0 to Palette.Count-1 do
+        { Can't use indexof, as compare must be case sensitive }
+        if code = Palette[color] then begin
+          img.pixels[r-1,imgindex] := color;
+          Break;
+        end;
        end;
    end;

Reply by email

Michael Van Canneyt
to Colin Western
Colin Western wrote 20 lines
I have spotted a problem with TFPReaderXPM, in that it uses a case insensitive compare on the colour symbols. I think it needs the following: diff -uNr fpc/fcl/image/fpreadxpm.pp fpc.w/fcl/image/fpreadxpm.pp --- fpc/fcl/image/fpreadxpm.pp 2003-08-17 19:33:04.000000000 +0100 +++ fpc.w/fcl/image/fpreadxpm.pp 2004-01-17 11:54:32.000000000 +0000 @@ -268,8 +268,12 @@ begin code := copy(s, p, cpp); inc(p,cpp); - color := Palette.indexof (code); - img.pixels[r-1,imgindex] := color; + for color := 0 to Palette.Count-1 do + { Can't use indexof, as compare must be case sensitive } + if code = Palette[color] then begin + img.pixels[r-1,imgindex] := color; + Break; + end; end; end;

The XPM reader is scheduled for a rewrite - it's quite slow at the moment, but I will apply the patch for the time being.

Thanks for reporting this !

Michael.

Reply by email