- Added wxDocManager::FindTemplate() (troelsk).
- Return bool, not void, from wxImage::ConvertAlphaToMask() (troelsk).
- Fixed resizing columns in wxGrid when they were reordered.
+- Added wxImage::Rotate180() (Jeff Tupper).
MSW:
bool interpolating = true, wxPoint * offset_after_rotation = NULL) const;
wxImage Rotate90( bool clockwise = true ) const;
+ wxImage Rotate180() const;
wxImage Mirror( bool horizontally = true ) const;
// replace one colour with another
*/
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
the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0
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 image;