add wxImage::Clear (patch by troelsk); closes #10141

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi 2009-01-09 15:35:59 +00:00
parent ecba92ec08
commit fc3762b5fc
4 changed files with 24 additions and 8 deletions

View File

@ -240,6 +240,9 @@ public:
bool Create( char** xpmData ) { return Create(const_cast<const char* const*>(xpmData)); } bool Create( char** xpmData ) { return Create(const_cast<const char* const*>(xpmData)); }
#endif #endif
void Destroy(); void Destroy();
// initialize the image data with zeroes
void Clear(unsigned char value = 0);
// creates an identical copy of the image (the = operator // creates an identical copy of the image (the = operator
// just raises the ref count) // just raises the ref count)

View File

@ -566,12 +566,20 @@ public:
@param height @param height
The height of the image in pixels. The height of the image in pixels.
@param clear @param clear
If @true, initialize the image data with zeros. If @true, initialize the image data with zeroes.
@return @true if the call succeeded, @false otherwise. @return @true if the call succeeded, @false otherwise.
*/ */
bool Create(int width, int height, bool clear = true); bool Create(int width, int height, bool clear = true);
/**
Initialize the image data with zeroes (the default) or with the
byte value given as @a value.
@since 2.9.0
*/
void Clear(unsigned char value = 0);
/** /**
Destroys the image data. Destroys the image data.
*/ */

View File

@ -50,7 +50,7 @@
// what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single // what to test (in alphabetic order)? Define TEST_ALL to 0 to do a single
// test, define it to 1 to do all tests. // test, define it to 1 to do all tests.
#define TEST_ALL 1 #define TEST_ALL 0
#if TEST_ALL #if TEST_ALL
@ -89,7 +89,7 @@
#define TEST_WCHAR #define TEST_WCHAR
#define TEST_ZIP #define TEST_ZIP
#else // #if TEST_ALL #else // #if TEST_ALL
#define TEST_EXECUTE #define TEST_FTP
#endif #endif
// some tests are interactive, define this to run them // some tests are interactive, define this to run them
@ -2405,8 +2405,6 @@ static void TestSocketClient()
#include "wx/protocol/ftp.h" #include "wx/protocol/ftp.h"
static wxFTP ftp;
#define FTP_ANONYMOUS #define FTP_ANONYMOUS
#ifdef FTP_ANONYMOUS #ifdef FTP_ANONYMOUS

View File

@ -195,13 +195,15 @@ bool wxImage::Create( int width, int height, bool clear )
return false; return false;
} }
if (clear)
memset(M_IMGDATA->m_data, 0, width*height*3);
M_IMGDATA->m_width = width; M_IMGDATA->m_width = width;
M_IMGDATA->m_height = height; M_IMGDATA->m_height = height;
M_IMGDATA->m_ok = true; M_IMGDATA->m_ok = true;
if (clear)
{
Clear();
}
return true; return true;
} }
@ -246,6 +248,11 @@ void wxImage::Destroy()
UnRef(); UnRef();
} }
void wxImage::Clear(unsigned char value)
{
memset(M_IMGDATA->m_data, value, M_IMGDATA->m_width*M_IMGDATA->m_height*3);
}
wxObjectRefData* wxImage::CreateRefData() const wxObjectRefData* wxImage::CreateRefData() const
{ {
return new wxImageRefData; return new wxImageRefData;