Color table overflow when exporting to GIF

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Thomas
Newbie
Newbie
Posts: 10
Joined: Thu Nov 25, 2004 5:00 am
Location: Calgary, Canada
Contact:

Color table overflow when exporting to GIF

Post by Thomas » Tue Feb 01, 2005 5:18 pm

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

Thomas
Newbie
Newbie
Posts: 10
Joined: Thu Nov 25, 2004 5:00 am
Location: Calgary, Canada
Contact:

Post by Thomas » Thu Feb 03, 2005 10:16 pm

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;

Rob
Newbie
Newbie
Posts: 1
Joined: Tue Apr 20, 2004 4:00 am

Post by Rob » Thu Nov 03, 2005 11:14 am

Thx, I came across the same problem.
By the way: don't forget to free your TGifImage object :wink:

Post Reply