}
else
{
- wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
+ wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
GetAllFormats( pFormats
,vDir
);
size_t wxFileDataObject::GetDataSize() const
{
- size_t nRes = 0;
+ size_t nRes = 0;
for (size_t i = 0; i < m_filenames.GetCount(); i++)
{
{
m_filenames.Empty();
- wxString sFile( (const char *)pBuf); /* char, not wxChar */
+ wxString sFile( (const char *)pBuf); /* char, not wxChar */
AddFile(sFile);
}
wxBitmapDataObject::wxBitmapDataObject(
- const wxBitmap& rBitmap
+ const wxBitmap& rBitmap
)
: wxBitmapDataObjectBase(rBitmap)
{
Init();
-
- DoConvertToPng();
+ if ( m_bitmap.Ok() )
+ {
+ m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
+ }
}
wxBitmapDataObject::~wxBitmapDataObject()
const wxBitmap& rBitmap
)
{
- ClearAll();
+ Clear();
wxBitmapDataObjectBase::SetBitmap(rBitmap);
- DoConvertToPng();
+ if ( m_bitmap.Ok() )
+ {
+ m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
+ }
+}
+
+void wxBitmapDataObject::Init()
+{
+ m_pictHandle = NULL ;
+ m_pictCreated = false ;
+}
+
+void wxBitmapDataObject::Clear()
+{
+ if ( m_pictCreated && m_pictHandle )
+ {
+ KillPicture( (PicHandle) m_pictHandle ) ;
+ }
+ m_pictHandle = NULL ;
}
bool wxBitmapDataObject::GetDataHere(
void* pBuf
) const
{
- if (!m_pngSize)
+ if (!m_pictHandle)
{
wxFAIL_MSG(wxT("attempt to copy empty bitmap failed"));
return FALSE;
}
- memcpy(pBuf, m_pngData, m_pngSize);
+ memcpy(pBuf, *(Handle)m_pictHandle, GetHandleSize((Handle)m_pictHandle));
return TRUE;
}
+size_t wxBitmapDataObject::GetDataSize() const
+{
+ return GetHandleSize((Handle)m_pictHandle) ;
+}
+
bool wxBitmapDataObject::SetData(
size_t nSize
, const void* pBuf
)
{
Clear();
- m_pngSize = nSize;
- m_pngData = malloc(m_pngSize);
-
- memcpy(m_pngData, pBuf, m_pngSize);
-
- wxMemoryInputStream vMstream((char*)m_pngData, m_pngSize);
- wxImage vImage;
- wxPNGHandler vHandler;
-
- if (!vHandler.LoadFile(&vImage, vMstream))
- {
- return FALSE;
- }
-
- m_bitmap = vImage.ConvertToBitmap();
+ PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
+ memcpy( *picHandle , pBuf , nSize ) ;
+ m_pictHandle = picHandle ;
+ m_pictCreated = false ;
+ Rect frame = (**picHandle).picFrame ;
+
+ m_bitmap.SetPict( picHandle ) ;
+ m_bitmap.SetWidth( frame.right - frame.left ) ;
+ m_bitmap.SetHeight( frame.bottom - frame.top ) ;
return m_bitmap.Ok();
}
-
-void wxBitmapDataObject::DoConvertToPng()
-{
- if (!m_bitmap.Ok())
- return;
-
- wxImage vImage(m_bitmap);
- wxPNGHandler vHandler;
- wxCountingOutputStream vCount;
-
- vHandler.SaveFile(&vImage, vCount);
-
- m_pngSize = vCount.GetSize() + 100; // sometimes the size seems to vary ???
- m_pngData = malloc(m_pngSize);
-
- wxMemoryOutputStream vMstream((char*) m_pngData, m_pngSize);
-
- vHandler.SaveFile(&vImage, vMstream );
-}
-