1. wxImageHandler::DoCanRead() introduced to solve the virtual function name
hiding problem 2. wxPNMHandler::CanRead() shouldn't use wxT() - should it? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,20 +62,22 @@ public:
|
|||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
|
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
|
||||||
virtual bool CanRead( const wxString& name );
|
bool CanRead( const wxString& name );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void SetName(const wxString& name) { m_name = name; }
|
void SetName(const wxString& name) { m_name = name; }
|
||||||
inline void SetExtension(const wxString& ext) { m_extension = ext; }
|
void SetExtension(const wxString& ext) { m_extension = ext; }
|
||||||
inline void SetType(long type) { m_type = type; }
|
void SetType(long type) { m_type = type; }
|
||||||
inline void SetMimeType(const wxString& type) { m_mime = type; }
|
void SetMimeType(const wxString& type) { m_mime = type; }
|
||||||
inline wxString GetName() const { return m_name; }
|
wxString GetName() const { return m_name; }
|
||||||
inline wxString GetExtension() const { return m_extension; }
|
wxString GetExtension() const { return m_extension; }
|
||||||
inline long GetType() const { return m_type; }
|
long GetType() const { return m_type; }
|
||||||
inline wxString GetMimeType() const { return m_mime; }
|
wxString GetMimeType() const { return m_mime; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual bool DoCanRead( wxInputStream& stream ) = 0;
|
||||||
|
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
wxString m_extension;
|
wxString m_extension;
|
||||||
wxString m_mime;
|
wxString m_mime;
|
||||||
@@ -105,10 +107,7 @@ public:
|
|||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
private:
|
|
||||||
// hiding base class virtuals again!
|
|
||||||
inline bool CanRead( const wxString& name ) { return(wxImageHandler::CanRead(name)); };
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -135,10 +134,7 @@ public:
|
|||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
private:
|
|
||||||
// hiding base class virtuals again!
|
|
||||||
inline bool CanRead( const wxString& name ) { return(wxImageHandler::CanRead(name)); };
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -163,10 +159,7 @@ public:
|
|||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
private:
|
|
||||||
// hiding base class virtuals again!
|
|
||||||
inline bool CanRead( const wxString& name ) { return(wxImageHandler::CanRead(name)); };
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -193,10 +186,7 @@ public:
|
|||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
private:
|
|
||||||
// hiding base class virtuals again!
|
|
||||||
inline bool CanRead( const wxString& name ) { return(wxImageHandler::CanRead(name)); };
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -223,10 +213,7 @@ public:
|
|||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
private:
|
|
||||||
// hiding base class virtuals again!
|
|
||||||
inline bool CanRead( const wxString& name ) { return(wxImageHandler::CanRead(name)); };
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -253,8 +240,7 @@ public:
|
|||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
virtual bool CanRead( wxInputStream& stream );
|
virtual bool DoCanRead( wxInputStream& stream );
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -401,7 +401,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBMPHandler::CanRead( wxInputStream& stream )
|
bool wxBMPHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
unsigned char hdr[2];
|
unsigned char hdr[2];
|
||||||
|
|
||||||
|
@@ -196,7 +196,7 @@ wxImage wxImage::GetSubImage( const wxRect &rect ) const
|
|||||||
wxCHECK_MSG( Ok(), image, wxT("invalid image") );
|
wxCHECK_MSG( Ok(), image, wxT("invalid image") );
|
||||||
|
|
||||||
wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (rect.GetRight()<=GetWidth()) && (rect.GetBottom()<=GetHeight())
|
wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (rect.GetRight()<=GetWidth()) && (rect.GetBottom()<=GetHeight())
|
||||||
, image, wxT("invalid subimage size") );
|
, image, wxT("invalid subimage size") );
|
||||||
|
|
||||||
int subwidth=rect.GetWidth();
|
int subwidth=rect.GetWidth();
|
||||||
const int subheight=rect.GetHeight();
|
const int subheight=rect.GetHeight();
|
||||||
@@ -220,7 +220,7 @@ wxImage wxImage::GetSubImage( const wxRect &rect ) const
|
|||||||
{
|
{
|
||||||
memcpy( subdata, data, subwidth);
|
memcpy( subdata, data, subwidth);
|
||||||
subdata+=subwidth;
|
subdata+=subwidth;
|
||||||
data+=width;
|
data+=width;
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
@@ -449,18 +449,18 @@ bool wxImage::LoadFile( wxInputStream& stream, long type )
|
|||||||
|
|
||||||
if (type==wxBITMAP_TYPE_ANY)
|
if (type==wxBITMAP_TYPE_ANY)
|
||||||
{
|
{
|
||||||
wxList &list=GetHandlers();
|
wxList &list=GetHandlers();
|
||||||
|
|
||||||
for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() )
|
for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
handler=(wxImageHandler*)node->GetData();
|
handler=(wxImageHandler*)node->GetData();
|
||||||
if (handler->CanRead( stream ))
|
if (handler->CanRead( stream ))
|
||||||
return handler->LoadFile( this, stream );
|
return handler->LoadFile( this, stream );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogWarning( wxT("No handler found for this image.") );
|
wxLogWarning( wxT("No handler found for this image.") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
handler = FindHandler(type);
|
handler = FindHandler(type);
|
||||||
@@ -642,11 +642,6 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxImageHandler::CanRead( wxInputStream& WXUNUSED(stream) )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxImageHandler::CanRead( const wxString& name )
|
bool wxImageHandler::CanRead( const wxString& name )
|
||||||
{
|
{
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
@@ -801,7 +796,7 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
// HDC memdc = ::CreateCompatibleDC( hdc );
|
// HDC memdc = ::CreateCompatibleDC( hdc );
|
||||||
// ::SelectObject( memdc, hbitmap);
|
// ::SelectObject( memdc, hbitmap);
|
||||||
// ::SetDIBitsToDevice( memdc, 0, 0, width, height,
|
// ::SetDIBitsToDevice( memdc, 0, 0, width, height,
|
||||||
// 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS);
|
// 0, 0, 0, height, (void *)lpBits, lpDIBh, DIB_RGB_COLORS);
|
||||||
// ::SelectObject( memdc, 0 );
|
// ::SelectObject( memdc, 0 );
|
||||||
// ::DeleteDC( memdc );
|
// ::DeleteDC( memdc );
|
||||||
}
|
}
|
||||||
@@ -1060,25 +1055,25 @@ wxBitmap wxImage::ConvertToBitmap() const
|
|||||||
{
|
{
|
||||||
static bool s_hasInitialized = FALSE;
|
static bool s_hasInitialized = FALSE;
|
||||||
|
|
||||||
if (!s_hasInitialized)
|
if (!s_hasInitialized)
|
||||||
{
|
{
|
||||||
gdk_rgb_init();
|
gdk_rgb_init();
|
||||||
s_hasInitialized = TRUE;
|
s_hasInitialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkGC *gc = gdk_gc_new( bitmap.GetPixmap() );
|
GdkGC *gc = gdk_gc_new( bitmap.GetPixmap() );
|
||||||
|
|
||||||
gdk_draw_rgb_image( bitmap.GetPixmap(),
|
gdk_draw_rgb_image( bitmap.GetPixmap(),
|
||||||
gc,
|
gc,
|
||||||
0, 0,
|
0, 0,
|
||||||
width, height,
|
width, height,
|
||||||
GDK_RGB_DITHER_NONE,
|
GDK_RGB_DITHER_NONE,
|
||||||
GetData(),
|
GetData(),
|
||||||
width*3 );
|
width*3 );
|
||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1282,7 +1277,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
for (int i = 0; i < bitmap.GetWidth(); i++)
|
for (int i = 0; i < bitmap.GetWidth(); i++)
|
||||||
{
|
{
|
||||||
wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
|
wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||||
pixel = wxINT32_SWAP_ON_BE( pixel );
|
pixel = wxINT32_SWAP_ON_BE( pixel );
|
||||||
if (bpp <= 8)
|
if (bpp <= 8)
|
||||||
{
|
{
|
||||||
data[pos] = cmap->colors[pixel].red >> 8;
|
data[pos] = cmap->colors[pixel].red >> 8;
|
||||||
|
@@ -79,7 +79,7 @@ bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image),
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGIFHandler::CanRead( wxInputStream& stream )
|
bool wxGIFHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
wxGIFDecoder *decod;
|
wxGIFDecoder *decod;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
@@ -28,8 +28,9 @@
|
|||||||
#include "wx/debug.h"
|
#include "wx/debug.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
extern "C" {
|
extern "C"
|
||||||
#include "jpeglib.h"
|
{
|
||||||
|
#include "jpeglib.h"
|
||||||
}
|
}
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
@@ -99,7 +100,7 @@ void jpeg_wxio_src( j_decompress_ptr cinfo, wxInputStream& infile )
|
|||||||
{
|
{
|
||||||
my_src_ptr src;
|
my_src_ptr src;
|
||||||
|
|
||||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||||
cinfo->src = (struct jpeg_source_mgr *)
|
cinfo->src = (struct jpeg_source_mgr *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
sizeof(my_source_mgr));
|
sizeof(my_source_mgr));
|
||||||
@@ -122,9 +123,9 @@ void jpeg_wxio_src( j_decompress_ptr cinfo, wxInputStream& infile )
|
|||||||
// JPEG error manager:
|
// JPEG error manager:
|
||||||
|
|
||||||
struct my_error_mgr {
|
struct my_error_mgr {
|
||||||
struct jpeg_error_mgr pub; /* "public" fields */
|
struct jpeg_error_mgr pub; /* "public" fields */
|
||||||
|
|
||||||
jmp_buf setjmp_buffer; /* for return to caller */
|
jmp_buf setjmp_buffer; /* for return to caller */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct my_error_mgr * my_error_ptr;
|
typedef struct my_error_mgr * my_error_ptr;
|
||||||
@@ -215,7 +216,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef my_destination_mgr * my_dest_ptr;
|
typedef my_destination_mgr * my_dest_ptr;
|
||||||
|
|
||||||
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
||||||
|
|
||||||
METHODDEF(void) init_destination (j_compress_ptr cinfo)
|
METHODDEF(void) init_destination (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
@@ -252,7 +253,7 @@ GLOBAL(void) jpeg_wxio_dest (j_compress_ptr cinfo, wxOutputStream& outfile)
|
|||||||
{
|
{
|
||||||
my_dest_ptr dest;
|
my_dest_ptr dest;
|
||||||
|
|
||||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
sizeof(my_destination_mgr));
|
sizeof(my_destination_mgr));
|
||||||
@@ -269,9 +270,9 @@ bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
|
|||||||
{
|
{
|
||||||
struct jpeg_compress_struct cinfo;
|
struct jpeg_compress_struct cinfo;
|
||||||
struct my_error_mgr jerr;
|
struct my_error_mgr jerr;
|
||||||
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
|
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
|
||||||
JSAMPLE *image_buffer;
|
JSAMPLE *image_buffer;
|
||||||
int stride; /* physical row width in image buffer */
|
int stride; /* physical row width in image buffer */
|
||||||
|
|
||||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||||
jerr.pub.error_exit = my_error_exit;
|
jerr.pub.error_exit = my_error_exit;
|
||||||
@@ -298,7 +299,7 @@ bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
|
|||||||
jpeg_set_defaults(&cinfo);
|
jpeg_set_defaults(&cinfo);
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
stride = cinfo.image_width * 3; /* JSAMPLEs per row in image_buffer */
|
stride = cinfo.image_width * 3; /* JSAMPLEs per row in image_buffer */
|
||||||
image_buffer = image->GetData();
|
image_buffer = image->GetData();
|
||||||
while (cinfo.next_scanline < cinfo.image_height) {
|
while (cinfo.next_scanline < cinfo.image_height) {
|
||||||
row_pointer[0] = &image_buffer[cinfo.next_scanline * stride];
|
row_pointer[0] = &image_buffer[cinfo.next_scanline * stride];
|
||||||
@@ -311,7 +312,7 @@ bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxJPEGHandler::CanRead( wxInputStream& stream )
|
bool wxJPEGHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
unsigned char hdr[2];
|
unsigned char hdr[2];
|
||||||
|
|
||||||
|
@@ -263,7 +263,7 @@ bool wxPCXHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPCXHandler::CanRead( wxInputStream& stream )
|
bool wxPCXHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
off_t pos;
|
off_t pos;
|
||||||
|
@@ -278,7 +278,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!verbose) png_set_error_fn(png_ptr, (png_voidp)NULL, png_silent_error, png_silent_warning);
|
if (!verbose) png_set_error_fn(png_ptr, (png_voidp)NULL, png_silent_error, png_silent_warning);
|
||||||
|
|
||||||
png_infop info_ptr = png_create_info_struct(png_ptr);
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (info_ptr == NULL)
|
if (info_ptr == NULL)
|
||||||
@@ -324,7 +324,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos
|
|||||||
data[(x << 2) + 0] = *ptr++;
|
data[(x << 2) + 0] = *ptr++;
|
||||||
data[(x << 2) + 1] = *ptr++;
|
data[(x << 2) + 1] = *ptr++;
|
||||||
data[(x << 2) + 2] = *ptr++;
|
data[(x << 2) + 2] = *ptr++;
|
||||||
if (( !image->HasMask() ) || \
|
if (( !image->HasMask() ) || \
|
||||||
(data[(x << 2) + 0] != image->GetMaskRed()) || \
|
(data[(x << 2) + 0] != image->GetMaskRed()) || \
|
||||||
(data[(x << 2) + 1] != image->GetMaskGreen()) || \
|
(data[(x << 2) + 1] != image->GetMaskGreen()) || \
|
||||||
(data[(x << 2) + 2] != image->GetMaskBlue()))
|
(data[(x << 2) + 2] != image->GetMaskBlue()))
|
||||||
@@ -347,7 +347,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPNGHandler::CanRead( wxInputStream& stream )
|
bool wxPNGHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
unsigned char hdr[4];
|
unsigned char hdr[4];
|
||||||
|
|
||||||
|
@@ -73,15 +73,15 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE
|
|||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case wxT('2'):
|
case wxT('2'):
|
||||||
wxLogError(wxT("Loading Grey Ascii PNM image is not yet implemented."));
|
wxLogError(wxT("Loading Grey Ascii PNM image is not yet implemented."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case wxT('5'):
|
case wxT('5'):
|
||||||
wxLogError(wxT("Loading Grey Raw PNM image is not yet implemented."));
|
wxLogError(wxT("Loading Grey Raw PNM image is not yet implemented."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case wxT('3'): case wxT('6'): break;
|
case wxT('3'): case wxT('6'): break;
|
||||||
default :
|
default :
|
||||||
wxLogError(wxT("Loading PNM image : file not recognized."));
|
wxLogError(wxT("Loading PNM image : file not recognized."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_stream >> line; // for the \n
|
text_stream >> line; // for the \n
|
||||||
@@ -96,25 +96,25 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSE
|
|||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
wxLogError( wxT("Cannot allocate RAM for RGB data in PNM file.") );
|
wxLogError( wxT("Cannot allocate RAM for RGB data in PNM file.") );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c=='3') // Ascii RBG
|
if (c=='3') // Ascii RBG
|
||||||
{
|
{
|
||||||
wxUint32 value, size=3*width*height;
|
wxUint32 value, size=3*width*height;
|
||||||
for (wxUint32 i=0; i<size; ++i)
|
for (wxUint32 i=0; i<size; ++i)
|
||||||
{
|
{
|
||||||
//this is very slow !!!
|
//this is very slow !!!
|
||||||
//I wonder how we can make any better ?
|
//I wonder how we can make any better ?
|
||||||
value=text_stream.Read32();
|
value=text_stream.Read32();
|
||||||
*ptr++=(unsigned char)value;
|
*ptr++=(unsigned char)value;
|
||||||
|
|
||||||
if (buf_stream.LastError()!=wxSTREAM_NOERROR)
|
if (buf_stream.LastError()!=wxSTREAM_NOERROR)
|
||||||
{
|
{
|
||||||
wxLogError(wxT("Loading PNM image : file seems truncated."));
|
wxLogError(wxT("Loading PNM image : file seems truncated."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c=='6') // Raw RGB
|
if (c=='6') // Raw RGB
|
||||||
buf_stream.Read( ptr, 3*width*height );
|
buf_stream.Read( ptr, 3*width*height );
|
||||||
@@ -137,19 +137,22 @@ bool wxPNMHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool WXUNUS
|
|||||||
return (stream.LastError()==wxStream_NOERROR);
|
return (stream.LastError()==wxStream_NOERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPNMHandler::CanRead( wxInputStream& stream )
|
bool wxPNMHandler::DoCanRead( wxInputStream& stream )
|
||||||
{
|
{
|
||||||
off_t pos=stream.TellI();
|
off_t pos = stream.TellI();
|
||||||
|
|
||||||
Skip_Comment(stream);
|
Skip_Comment(stream);
|
||||||
|
|
||||||
if (stream.GetC()==wxT('P'))
|
if ( stream.GetC() == 'P' )
|
||||||
switch (stream.GetC())
|
{
|
||||||
{
|
switch (stream.GetC())
|
||||||
case wxT('3'): case wxT('6'):
|
{
|
||||||
stream.SeekI(pos);
|
case '3':
|
||||||
return TRUE;
|
case '6':
|
||||||
}
|
stream.SeekI(pos);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stream.SeekI(pos);
|
stream.SeekI(pos);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user