Accomodate changes in CountColours

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia 1999-12-16 12:22:37 +00:00
parent cc9f7d7939
commit d32548aa77

View File

@ -36,7 +36,7 @@
#include "wx/object.h"
//-----------------------------------------------------------------------------
// PCX decoding
// RLE encoding and decoding
//-----------------------------------------------------------------------------
void RLEencode(unsigned char *p, unsigned int size, wxOutputStream& s)
@ -76,7 +76,6 @@ void RLEencode(unsigned char *p, unsigned int size, wxOutputStream& s)
}
}
// Write the last one and return;
//
if ((cont > 1) || ((last & 0xC0) == 0xC0))
@ -120,7 +119,11 @@ void RLEdecode(unsigned char *p, unsigned int size, wxInputStream& s)
}
/* PCX header */
//-----------------------------------------------------------------------------
// PCX reading and saving
//-----------------------------------------------------------------------------
// PCX header
#define HDR_MANUFACTURER 0
#define HDR_VERSION 1
#define HDR_ENCODING 2
@ -278,29 +281,20 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
unsigned char *src; // pointer into wxImage data
unsigned int width, height; // size of the image
unsigned int bytesperline; // bytes per line (each plane)
int nplanes; // number of planes
int format; // image format (8 bit, 24 bit)
int nplanes = 3; // number of planes
int format = wxPCX_24BIT; // image format (8 bit, 24 bit)
wxHashTable h(wxKEY_INTEGER); // image histogram
unsigned long ncolours; // num. of different colours
unsigned long key; // key in the hashtable
unsigned int i;
// Get the histogram of the image, and decide whether to save
// as 8 bit or 24 bit, according to the number of colours.
// See if we can save as 8 bit.
//
ncolours = image->CountColours(257);
if (ncolours <= 256)
if (image->CountColours(256) <= 256)
{
image->ComputeHistogram(h);
format = wxPCX_8BIT;
nplanes = 1;
}
else
{
format = wxPCX_24BIT;
nplanes = 3;
}
// Get image dimensions, calculate bytesperline (must be even,
// according to PCX specs) and allocate space for one complete
@ -374,7 +368,7 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
break;
}
}
RLEencode(p, bytesperline * nplanes, stream);
}