Page 1 of 1

Color table overflow when exporting to GIF

Posted: Tue Feb 01, 2005 5:18 pm
by 9340003
When I attempt to export a chart to GIF, I get "Color table overflow". Here is the code:

Code: Select all

with TGIFExportFormat.Create do
try
  Panel := SomeChart;
  SaveToFile('SomeFilename.gif');
finally
  Free;
end;
However, the same chart exports just fine when using TeeExport.
This happens in 32 and 24 bit screen resolution. With 16 bit screen resolution, both outputs are just fine.
The chart has a color grid series.
What should I set before SaveToFile in the above code?

Thanks,
Thomas

Posted: Thu Feb 03, 2005 10:16 pm
by 9340003
Solved my own problem :)

Code: Select all

var
  tmpBitmap: TBitmap;
  r: TRect;
begin
  if dlgSaveGIF.Execute then
    with TGIFExportFormat.Create do
    try
      Panel := chBaseMap;
      //The key is to create TGIFImage and then set ColorReduction
      with TGIFImage.Create do
      begin
        DitherMode := dmNearest;
        Compression := gcLZW;
        ColorReduction := rmQuantize;
        r.Left := 0;
        r.Top := 0;
        r.Right := Panel.Width;
        r.Bottom := Panel.Height;
        tmpBitmap:=Panel.TeeCreateBitmap(Panel.Color,r);
        try
          Assign(tmpBitmap);
        finally
          tmpBitmap.Free;
        end;
        SaveToFile(dlgSaveGif.FileName);
      end;
    finally
      Free;
    end;
end;

Posted: Thu Nov 03, 2005 11:14 am
by 9232181
Thx, I came across the same problem.
By the way: don't forget to free your TGifImage object :wink: