The Lesser wxMask Refactoring: merged wxMGL and wxDFB version, added wxMaskBase which could/should be used by other ports later

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41495 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-09-28 23:02:39 +00:00
parent 4353a8df6e
commit 87f83ac867
12 changed files with 338 additions and 332 deletions

76
src/generic/mask.cpp Normal file
View File

@@ -0,0 +1,76 @@
///////////////////////////////////////////////////////////////////////////////
// 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.Ok() )
return false;
m_bitmap = wxBitmap(image, 1);
return m_bitmap.Ok();
#else // !wxUSE_IMAGE
wxUnusedVar(bitmap);
wxUnusedVar(colour);
return false;
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
}
bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
{
wxCHECK_MSG( bitmap.Ok(), 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