removed implicit dependency on wxPNGHandler from wxGTK's wxBitmapDataObject

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2002-03-03 23:25:28 +00:00
parent bc5a847c1b
commit bd3b7e098d
2 changed files with 30 additions and 34 deletions

View File

@ -330,46 +330,44 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
{
Clear();
#if wxUSE_LIBPNG
wxCHECK_MSG( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL,
FALSE, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") );
m_pngSize = size;
m_pngData = malloc(m_pngSize);
memcpy( m_pngData, buf, m_pngSize );
memcpy(m_pngData, buf, m_pngSize);
wxMemoryInputStream mstream( (char*) m_pngData, m_pngSize );
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
wxImage image;
wxPNGHandler handler;
if ( !handler.LoadFile( &image, mstream ) )
if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) )
{
return FALSE;
}
m_bitmap = image.ConvertToBitmap();
m_bitmap = wxBitmap(image);
return m_bitmap.Ok();
#else
return FALSE;
#endif
}
void wxBitmapDataObject::DoConvertToPng()
{
#if wxUSE_LIBPNG
if (!m_bitmap.Ok())
if ( !m_bitmap.Ok() )
return;
wxImage image( m_bitmap );
wxPNGHandler handler;
wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL,
wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") );
wxImage image(m_bitmap);
wxCountingOutputStream count;
handler.SaveFile( &image, count );
image.SaveFile(count, wxBITMAP_TYPE_PNG);
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
m_pngData = malloc(m_pngSize);
wxMemoryOutputStream mstream( (char*) m_pngData, m_pngSize );
handler.SaveFile( &image, mstream );
#endif
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
image.SaveFile(mstream, wxBITMAP_TYPE_PNG);
}

View File

@ -330,46 +330,44 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
{
Clear();
#if wxUSE_LIBPNG
wxCHECK_MSG( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL,
FALSE, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") );
m_pngSize = size;
m_pngData = malloc(m_pngSize);
memcpy( m_pngData, buf, m_pngSize );
memcpy(m_pngData, buf, m_pngSize);
wxMemoryInputStream mstream( (char*) m_pngData, m_pngSize );
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
wxImage image;
wxPNGHandler handler;
if ( !handler.LoadFile( &image, mstream ) )
if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) )
{
return FALSE;
}
m_bitmap = image.ConvertToBitmap();
m_bitmap = wxBitmap(image);
return m_bitmap.Ok();
#else
return FALSE;
#endif
}
void wxBitmapDataObject::DoConvertToPng()
{
#if wxUSE_LIBPNG
if (!m_bitmap.Ok())
if ( !m_bitmap.Ok() )
return;
wxImage image( m_bitmap );
wxPNGHandler handler;
wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL,
wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") );
wxImage image(m_bitmap);
wxCountingOutputStream count;
handler.SaveFile( &image, count );
image.SaveFile(count, wxBITMAP_TYPE_PNG);
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
m_pngData = malloc(m_pngSize);
wxMemoryOutputStream mstream( (char*) m_pngData, m_pngSize );
handler.SaveFile( &image, mstream );
#endif
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
image.SaveFile(mstream, wxBITMAP_TYPE_PNG);
}