Add wxImage::Rotate180() function.
Closes #12679. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -429,6 +429,7 @@ All (GUI):
|
|||||||
- Added wxDocManager::FindTemplate() (troelsk).
|
- Added wxDocManager::FindTemplate() (troelsk).
|
||||||
- Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk).
|
- Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk).
|
||||||
- Fixed resizing columns in wxGrid when they were reordered.
|
- Fixed resizing columns in wxGrid when they were reordered.
|
||||||
|
- Added wxImage::Rotate180() (Jeff Tupper).
|
||||||
|
|
||||||
MSW:
|
MSW:
|
||||||
|
|
||||||
|
@@ -347,6 +347,7 @@ public:
|
|||||||
bool interpolating = true, wxPoint * offset_after_rotation = NULL) const;
|
bool interpolating = true, wxPoint * offset_after_rotation = NULL) const;
|
||||||
|
|
||||||
wxImage Rotate90( bool clockwise = true ) const;
|
wxImage Rotate90( bool clockwise = true ) const;
|
||||||
|
wxImage Rotate180() const;
|
||||||
wxImage Mirror( bool horizontally = true ) const;
|
wxImage Mirror( bool horizontally = true ) const;
|
||||||
|
|
||||||
// replace one colour with another
|
// replace one colour with another
|
||||||
|
@@ -728,6 +728,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxImage Rotate90(bool clockwise = true) const;
|
wxImage Rotate90(bool clockwise = true) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a copy of the image rotated by 180 degrees.
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
wxImage Rotate180() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Rotates the hue of each pixel in the image by @e angle, which is a double in
|
Rotates the hue of each pixel in the image by @e angle, which is a double in
|
||||||
the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0
|
the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0
|
||||||
|
@@ -1128,6 +1128,62 @@ wxImage wxImage::Rotate90( bool clockwise ) const
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxImage wxImage::Rotate180() const
|
||||||
|
{
|
||||||
|
wxImage image;
|
||||||
|
|
||||||
|
wxCHECK_MSG( Ok(), image, wxS("invalid image") );
|
||||||
|
|
||||||
|
image.Create( M_IMGDATA->m_width, M_IMGDATA->m_height, false );
|
||||||
|
|
||||||
|
unsigned char *data = image.GetData();
|
||||||
|
unsigned char *alpha = NULL;
|
||||||
|
|
||||||
|
wxCHECK_MSG( data, image, wxS("unable to create image") );
|
||||||
|
|
||||||
|
if ( M_IMGDATA->m_alpha != NULL )
|
||||||
|
{
|
||||||
|
image.SetAlpha();
|
||||||
|
alpha = image.GetAlpha();
|
||||||
|
wxCHECK_MSG( alpha, image, wxS("unable to create alpha channel") );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( M_IMGDATA->m_hasMask )
|
||||||
|
image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue );
|
||||||
|
|
||||||
|
long height = M_IMGDATA->m_height;
|
||||||
|
long width = M_IMGDATA->m_width;
|
||||||
|
|
||||||
|
const unsigned char *source_data = M_IMGDATA->m_data;
|
||||||
|
unsigned char *target_data = data + width * height * 3;
|
||||||
|
|
||||||
|
for (long j = 0; j < height; j++)
|
||||||
|
{
|
||||||
|
for (long i = 0; i < width; i++)
|
||||||
|
{
|
||||||
|
target_data -= 3;
|
||||||
|
memcpy( target_data, source_data, 3 );
|
||||||
|
source_data += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( alpha )
|
||||||
|
{
|
||||||
|
const unsigned char *src_alpha = M_IMGDATA->m_alpha;
|
||||||
|
unsigned char *dest_alpha = alpha + width * height;
|
||||||
|
|
||||||
|
for (long j = 0; j < height; ++j)
|
||||||
|
{
|
||||||
|
for (long i = 0; i < width; ++i)
|
||||||
|
{
|
||||||
|
*(--dest_alpha) = *(src_alpha++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
wxImage wxImage::Mirror( bool horizontally ) const
|
wxImage wxImage::Mirror( bool horizontally ) const
|
||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
|
Reference in New Issue
Block a user