Applied patch [ 1183803 ] PNM: support for ascii grey + raw grey
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34261 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
40003
samples/image/horse_ag.pnm
Normal file
40003
samples/image/horse_ag.pnm
Normal file
File diff suppressed because it is too large
Load Diff
17
samples/image/horse_rg.pnm
Normal file
17
samples/image/horse_rg.pnm
Normal file
File diff suppressed because one or more lines are too long
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<wx-data id="data">
|
<wx-data id="data">
|
||||||
<files>
|
<files>
|
||||||
horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm
|
horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm
|
||||||
horse.tif horse.xpm horse.cur horse.ico horse3.ani
|
horse.tif horse.xpm horse.cur horse.ico horse3.ani
|
||||||
smile.xbm
|
smile.xbm
|
||||||
</files>
|
</files>
|
||||||
|
@@ -81,6 +81,9 @@ public:
|
|||||||
wxBitmap *my_square;
|
wxBitmap *my_square;
|
||||||
wxBitmap *my_anti;
|
wxBitmap *my_anti;
|
||||||
|
|
||||||
|
wxBitmap *my_horse_asciigrey_pnm;
|
||||||
|
wxBitmap *my_horse_rawgrey_pnm;
|
||||||
|
|
||||||
int xH, yH ;
|
int xH, yH ;
|
||||||
int m_ani_images ;
|
int m_ani_images ;
|
||||||
|
|
||||||
@@ -410,6 +413,9 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
|||||||
my_square = (wxBitmap*) NULL;
|
my_square = (wxBitmap*) NULL;
|
||||||
my_anti = (wxBitmap*) NULL;
|
my_anti = (wxBitmap*) NULL;
|
||||||
|
|
||||||
|
my_horse_asciigrey_pnm = (wxBitmap*) NULL;
|
||||||
|
my_horse_rawgrey_pnm = (wxBitmap*) NULL;
|
||||||
|
|
||||||
m_ani_images = 0 ;
|
m_ani_images = 0 ;
|
||||||
|
|
||||||
SetBackgroundColour(* wxWHITE);
|
SetBackgroundColour(* wxWHITE);
|
||||||
@@ -506,6 +512,20 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
|||||||
wxLogError(wxT("Can't load PNM image"));
|
wxLogError(wxT("Can't load PNM image"));
|
||||||
else
|
else
|
||||||
my_horse_pnm = new wxBitmap( image );
|
my_horse_pnm = new wxBitmap( image );
|
||||||
|
|
||||||
|
image.Destroy();
|
||||||
|
|
||||||
|
if ( !image.LoadFile( dir + _T("horse_ag.pnm"), wxBITMAP_TYPE_PNM ) )
|
||||||
|
wxLogError(wxT("Can't load PNM image"));
|
||||||
|
else
|
||||||
|
my_horse_asciigrey_pnm = new wxBitmap( image );
|
||||||
|
|
||||||
|
image.Destroy();
|
||||||
|
|
||||||
|
if ( !image.LoadFile( dir + _T("horse_rg.pnm"), wxBITMAP_TYPE_PNM ) )
|
||||||
|
wxLogError(wxT("Can't load PNM image"));
|
||||||
|
else
|
||||||
|
my_horse_rawgrey_pnm = new wxBitmap( image );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_LIBTIFF
|
#if wxUSE_LIBTIFF
|
||||||
@@ -622,6 +642,8 @@ MyCanvas::~MyCanvas()
|
|||||||
delete my_smile_xbm;
|
delete my_smile_xbm;
|
||||||
delete my_square;
|
delete my_square;
|
||||||
delete my_anti;
|
delete my_anti;
|
||||||
|
delete my_horse_asciigrey_pnm;
|
||||||
|
delete my_horse_rawgrey_pnm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||||
@@ -675,6 +697,14 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
dc.DrawText( _T("PNM handler"), 30, 1285 );
|
dc.DrawText( _T("PNM handler"), 30, 1285 );
|
||||||
if (my_horse_pnm && my_horse_pnm->Ok())
|
if (my_horse_pnm && my_horse_pnm->Ok())
|
||||||
dc.DrawBitmap( *my_horse_pnm, 30, 1300 );
|
dc.DrawBitmap( *my_horse_pnm, 30, 1300 );
|
||||||
|
|
||||||
|
dc.DrawText( _T("PNM handler (ascii grey)"), 280, 1285 );
|
||||||
|
if (my_horse_asciigrey_pnm && my_horse_asciigrey_pnm->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_asciigrey_pnm, 280, 1300 );
|
||||||
|
|
||||||
|
dc.DrawText( _T("PNM handler (raw grey)"), 530, 1285 );
|
||||||
|
if (my_horse_rawgrey_pnm && my_horse_rawgrey_pnm->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_rawgrey_pnm, 530, 1300 );
|
||||||
|
|
||||||
dc.DrawText( _T("TIFF handler"), 30, 1515 );
|
dc.DrawText( _T("TIFF handler"), 30, 1515 );
|
||||||
if (my_horse_tiff && my_horse_tiff->Ok())
|
if (my_horse_tiff && my_horse_tiff->Ok())
|
||||||
|
@@ -68,13 +68,9 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
|||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case wxT('2'):
|
case wxT('2'): // ASCII Grey
|
||||||
if (verbose) wxLogError(_("Loading Grey Ascii PNM image is not yet implemented."));
|
case wxT('3'): // ASCII RGB
|
||||||
return false;
|
case wxT('5'): // RAW Grey
|
||||||
case wxT('5'):
|
|
||||||
if (verbose) wxLogError(_("Loading Grey Raw PNM image is not yet implemented."));
|
|
||||||
return false;
|
|
||||||
case wxT('3'):
|
|
||||||
case wxT('6'): break;
|
case wxT('6'): break;
|
||||||
default:
|
default:
|
||||||
if (verbose) wxLogError(_("PNM: File format is not recognized."));
|
if (verbose) wxLogError(_("PNM: File format is not recognized."));
|
||||||
@@ -97,6 +93,23 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (c=='2') // Ascii GREY
|
||||||
|
{
|
||||||
|
wxUint32 value, size=width*height;
|
||||||
|
for (wxUint32 i=0; i<size; ++i)
|
||||||
|
{
|
||||||
|
value=text_stream.Read32();
|
||||||
|
*ptr++=(unsigned char)value; // R
|
||||||
|
*ptr++=(unsigned char)value; // G
|
||||||
|
*ptr++=(unsigned char)value; // B
|
||||||
|
if ( !buf_stream )
|
||||||
|
{
|
||||||
|
if (verbose) wxLogError(_("PNM: File seems truncated."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (c=='3') // Ascii RBG
|
if (c=='3') // Ascii RBG
|
||||||
{
|
{
|
||||||
wxUint32 value, size=3*width*height;
|
wxUint32 value, size=3*width*height;
|
||||||
@@ -114,6 +127,23 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (c=='5') // Raw GREY
|
||||||
|
{
|
||||||
|
wxUint32 size=width*height;
|
||||||
|
unsigned char value;
|
||||||
|
for (wxUint32 i=0; i<size; ++i)
|
||||||
|
{
|
||||||
|
buf_stream.Read(&value,1);
|
||||||
|
*ptr++=value; // R
|
||||||
|
*ptr++=value; // G
|
||||||
|
*ptr++=value; // B
|
||||||
|
if ( !buf_stream )
|
||||||
|
{
|
||||||
|
if (verbose) wxLogError(_("PNM: File seems truncated."));
|
||||||
|
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 );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user