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:
@@ -330,7 +330,9 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
|
|||||||
{
|
{
|
||||||
Clear();
|
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_pngSize = size;
|
||||||
m_pngData = malloc(m_pngSize);
|
m_pngData = malloc(m_pngSize);
|
||||||
|
|
||||||
@@ -338,38 +340,34 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
|
|||||||
|
|
||||||
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
|
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
|
||||||
wxImage image;
|
wxImage image;
|
||||||
wxPNGHandler handler;
|
if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) )
|
||||||
if ( !handler.LoadFile( &image, mstream ) )
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bitmap = image.ConvertToBitmap();
|
m_bitmap = wxBitmap(image);
|
||||||
|
|
||||||
return m_bitmap.Ok();
|
return m_bitmap.Ok();
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapDataObject::DoConvertToPng()
|
void wxBitmapDataObject::DoConvertToPng()
|
||||||
{
|
{
|
||||||
#if wxUSE_LIBPNG
|
|
||||||
if ( !m_bitmap.Ok() )
|
if ( !m_bitmap.Ok() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
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);
|
wxImage image(m_bitmap);
|
||||||
wxPNGHandler handler;
|
|
||||||
|
|
||||||
wxCountingOutputStream count;
|
wxCountingOutputStream count;
|
||||||
handler.SaveFile( &image, count );
|
image.SaveFile(count, wxBITMAP_TYPE_PNG);
|
||||||
|
|
||||||
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
|
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
|
||||||
m_pngData = malloc(m_pngSize);
|
m_pngData = malloc(m_pngSize);
|
||||||
|
|
||||||
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
|
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
|
||||||
handler.SaveFile( &image, mstream );
|
image.SaveFile(mstream, wxBITMAP_TYPE_PNG);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -330,7 +330,9 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
|
|||||||
{
|
{
|
||||||
Clear();
|
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_pngSize = size;
|
||||||
m_pngData = malloc(m_pngSize);
|
m_pngData = malloc(m_pngSize);
|
||||||
|
|
||||||
@@ -338,38 +340,34 @@ bool wxBitmapDataObject::SetData(size_t size, const void *buf)
|
|||||||
|
|
||||||
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
|
wxMemoryInputStream mstream((char*) m_pngData, m_pngSize);
|
||||||
wxImage image;
|
wxImage image;
|
||||||
wxPNGHandler handler;
|
if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) )
|
||||||
if ( !handler.LoadFile( &image, mstream ) )
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bitmap = image.ConvertToBitmap();
|
m_bitmap = wxBitmap(image);
|
||||||
|
|
||||||
return m_bitmap.Ok();
|
return m_bitmap.Ok();
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapDataObject::DoConvertToPng()
|
void wxBitmapDataObject::DoConvertToPng()
|
||||||
{
|
{
|
||||||
#if wxUSE_LIBPNG
|
|
||||||
if ( !m_bitmap.Ok() )
|
if ( !m_bitmap.Ok() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
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);
|
wxImage image(m_bitmap);
|
||||||
wxPNGHandler handler;
|
|
||||||
|
|
||||||
wxCountingOutputStream count;
|
wxCountingOutputStream count;
|
||||||
handler.SaveFile( &image, count );
|
image.SaveFile(count, wxBITMAP_TYPE_PNG);
|
||||||
|
|
||||||
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
|
m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
|
||||||
m_pngData = malloc(m_pngSize);
|
m_pngData = malloc(m_pngSize);
|
||||||
|
|
||||||
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
|
wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
|
||||||
handler.SaveFile( &image, mstream );
|
image.SaveFile(mstream, wxBITMAP_TYPE_PNG);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user