projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
In bitmap.cpp, CreateFromImage, took GetWidth and GetHeight out of loop.
[wxWidgets.git]
/
src
/
gtk1
/
dataobj.cpp
diff --git
a/src/gtk1/dataobj.cpp
b/src/gtk1/dataobj.cpp
index e901b6ea57338cc732503d46303d8e916f278490..cfbf0deb8ac26dcbb17e949c212d5472c7657588 100644
(file)
--- a/
src/gtk1/dataobj.cpp
+++ b/
src/gtk1/dataobj.cpp
@@
-152,15
+152,18
@@
wxDataObject::wxDataObject()
bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const
{
size_t nFormatCount = GetFormatCount(dir);
bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const
{
size_t nFormatCount = GetFormatCount(dir);
- if ( nFormatCount == 1 ) {
+ if ( nFormatCount == 1 )
+ {
return format == GetPreferredFormat();
}
return format == GetPreferredFormat();
}
- else {
+ else
+ {
wxDataFormat *formats = new wxDataFormat[nFormatCount];
GetAllFormats(formats,dir);
size_t n;
wxDataFormat *formats = new wxDataFormat[nFormatCount];
GetAllFormats(formats,dir);
size_t n;
- for ( n = 0; n < nFormatCount; n++ ) {
+ for ( n = 0; n < nFormatCount; n++ )
+ {
if ( formats[n] == format )
break;
}
if ( formats[n] == format )
break;
}
@@
-204,7
+207,7
@@
size_t wxFileDataObject::GetDataSize() const
return res + 1;
}
return res + 1;
}
-bool wxFileDataObject::SetData(size_t
size
, const void *buf)
+bool wxFileDataObject::SetData(size_t
WXUNUSED(size)
, const void *buf)
{
// VZ: old format
#if 0
{
// VZ: old format
#if 0
@@
-327,40
+330,44
@@
bool wxBitmapDataObject::SetData(size_t size, const void *buf)
{
Clear();
{
Clear();
+ 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);
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;
wxImage image;
- wxPNGHandler handler;
- if ( !handler.LoadFile( &image, mstream ) )
+ if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) )
{
return FALSE;
}
{
return FALSE;
}
- m_bitmap =
image.ConvertToBitmap(
);
+ m_bitmap =
wxBitmap(image
);
return m_bitmap.Ok();
}
void wxBitmapDataObject::DoConvertToPng()
{
return m_bitmap.Ok();
}
void wxBitmapDataObject::DoConvertToPng()
{
- if (
!m_bitmap.Ok()
)
+ if (
!m_bitmap.Ok()
)
return;
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.ConvertToImage();
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_pngData = malloc(m_pngSize);
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
);
+ wxMemoryOutputStream mstream(
(char*) m_pngData, m_pngSize
);
+
image.SaveFile(mstream, wxBITMAP_TYPE_PNG
);
}
}