wxBitmap::GetNSImage(): Added trace messages. Release maskImage.

wxMask_CreateFromBitmapData(): Don't clobber byte past the end of dest buffer.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2004-02-09 03:27:47 +00:00
parent d351525a9b
commit 9a6e13a6f7

View File

@@ -157,12 +157,17 @@ WX_NSImage wxBitmap::GetNSImage(bool useMask) const
[nsimage addRepresentation: M_BITMAPDATA->m_cocoaNSBitmapImageRep]; [nsimage addRepresentation: M_BITMAPDATA->m_cocoaNSBitmapImageRep];
if(useMask && GetMask()) if(useMask && GetMask())
{ {
// Show before/after to prove that the bitmap itself is not changed
// even though we just composited onto the NSImage
wxLogTrace(wxTRACE_COCOA,"Before: bpp=%d",[M_BITMAPDATA->m_cocoaNSBitmapImageRep bitsPerPixel]);
NSImage *maskImage = [[NSImage alloc] NSImage *maskImage = [[NSImage alloc]
initWithSize:NSMakeSize(GetWidth(), GetHeight())]; initWithSize:NSMakeSize(GetWidth(), GetHeight())];
[maskImage addRepresentation: GetMask()->GetNSBitmapImageRep()]; [maskImage addRepresentation: GetMask()->GetNSBitmapImageRep()];
[nsimage lockFocus]; [nsimage lockFocus];
[maskImage compositeToPoint:NSZeroPoint operation:NSCompositeDestinationIn]; [maskImage compositeToPoint:NSZeroPoint operation:NSCompositeDestinationIn];
[nsimage unlockFocus]; [nsimage unlockFocus];
[maskImage release];
wxLogTrace(wxTRACE_COCOA,"After: bpp=%d",[M_BITMAPDATA->m_cocoaNSBitmapImageRep bitsPerPixel]);
} }
return nsimage; return nsimage;
} }
@@ -538,7 +543,8 @@ static bool wxMask_CreateFromBitmapData(PixelData srcData, const wxColour& colou
} }
// Handle the remaining 0-7 pixels in the row // Handle the remaining 0-7 pixels in the row
unsigned char *dstByte = dstRow + width_aligned/8; unsigned char *dstByte = dstRow + width_aligned/8;
*dstByte = 0; if(nCols%8>0)
*dstByte = 0;
for(int j=0; j<(nCols%8); ++j, ++p) for(int j=0; j<(nCols%8); ++j, ++p)
{ {
*dstByte += *dstByte +=