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