Small bugfix

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4958 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia 1999-12-15 12:32:22 +00:00
parent 89d0045628
commit faa7a70eaf

View File

@ -148,6 +148,7 @@ enum {
wxPCX_VERERR = 3 // error in pcx version number wxPCX_VERERR = 3 // error in pcx version number
}; };
// ReadPCX: // ReadPCX:
// Loads a PCX file into the wxImage object pointed by image. // Loads a PCX file into the wxImage object pointed by image.
// Returns wxPCX_OK on success, or an error code otherwise // Returns wxPCX_OK on success, or an error code otherwise
@ -288,10 +289,11 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
// Get the histogram of the image, and decide whether to save // Get the histogram of the image, and decide whether to save
// as 8 bit or 24 bit, according to the number of colours. // as 8 bit or 24 bit, according to the number of colours.
// //
ncolours = image->ComputeHistogram(h); ncolours = image->CountColours(257);
if (ncolours <= 256) if (ncolours <= 256)
{ {
image->ComputeHistogram(h);
format = wxPCX_8BIT; format = wxPCX_8BIT;
nplanes = 1; nplanes = 1;
} }
@ -358,10 +360,7 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
key = (r << 16) | (g << 8) | b; key = (r << 16) | (g << 8) | b;
hnode = (wxHNode *) h.Get(key); hnode = (wxHNode *) h.Get(key);
if (!hnode) p[i] = hnode->index;
wxLogError("!hnode");
else
p[i] = hnode->index;
} }
break; break;
} }
@ -398,15 +397,10 @@ int SavePCX(wxImage *image, wxOutputStream& stream)
key = node->GetKeyInteger(); key = node->GetKeyInteger();
hnode = (wxHNode *) node->GetData(); hnode = (wxHNode *) node->GetData();
if (!hnode) pal[3 * hnode->index] = (unsigned char)(key >> 16);
wxLogError("!hnode"); pal[3 * hnode->index + 1] = (unsigned char)(key >> 8);
else pal[3 * hnode->index + 2] = (unsigned char)(key);
{ delete hnode;
pal[3 * hnode->index] = (unsigned char)(key >> 16);
pal[3 * hnode->index + 1] = (unsigned char)(key >> 8);
pal[3 * hnode->index + 2] = (unsigned char)(key);
delete hnode;
}
} }
stream.PutC(12); stream.PutC(12);