Files
wxWidgets/src/generic/mask.cpp
Dimitri Schoolwerth a1b806b982 Replaced Ok() occurrences with IsOk() throughout trunk.
Additionally renamed wxOSX' private wxNativePrinterDC::Ok() function to IsOk().

Didn't deprecate the various Ok() functions: given the amount of changes already introduced in 3.0 a trivial one like this seems more suitable for after 3.0.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-05-03 16:29:04 +00:00

77 lines
2.1 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: src/generic/mask.cpp
// Purpose: generic wxMask implementation
// Author: Vadim Zeitlin
// Created: 2006-09-28
// RCS-ID: $Id$
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/bitmap.h"
#include "wx/image.h"
#endif // WX_PRECOMP
#if wxUSE_GENERIC_MASK
// ============================================================================
// wxMask implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
void wxMask::FreeData()
{
m_bitmap = wxNullBitmap;
}
bool wxMask::InitFromColour(const wxBitmap& bitmap, const wxColour& colour)
{
#if wxUSE_IMAGE
const wxColour clr(bitmap.QuantizeColour(colour));
wxImage imgSrc(bitmap.ConvertToImage());
imgSrc.SetMask(false);
wxImage image(imgSrc.ConvertToMono(clr.Red(), clr.Green(), clr.Blue()));
if ( !image.IsOk() )
return false;
m_bitmap = wxBitmap(image, 1);
return m_bitmap.IsOk();
#else // !wxUSE_IMAGE
wxUnusedVar(bitmap);
wxUnusedVar(colour);
return false;
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
}
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
{
wxCHECK_MSG( bitmap.IsOk(), false, wxT("Invalid bitmap") );
wxCHECK_MSG( bitmap.GetDepth() == 1, false, wxT("Cannot create mask from colour bitmap") );
m_bitmap = bitmap;
return true;
}
#endif // wxUSE_GENERIC_MASK