/*****************************************************************************
* win32_graphics.cpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: win32_graphics.cpp,v 1.3 2004/01/27 21:12:42 gbazin Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef WIN32_SKINS
#define WINVER 0x500
-#ifndef AC_SRC_ALPHA
-#define AC_SRC_ALPHA 1
-#endif
#include "win32_factory.hpp"
#include "win32_graphics.hpp"
#include "win32_window.hpp"
#include "../src/generic_bitmap.hpp"
+#ifndef AC_SRC_ALPHA
+#define AC_SRC_ALPHA 1
+#endif
+
Win32Graphics::Win32Graphics( intf_thread_t *pIntf, int width, int height ):
OSGraphics( pIntf ), m_width( width ), m_height( height ), m_hDC( NULL )
{
void Win32Graphics::drawBitmap( const GenericBitmap &rBitmap,
int xSrc, int ySrc, int xDest, int yDest,
- int width, int height )
+ int width, int height, bool blend )
{
// Get the bitmap size if necessary
if( width == -1 )
uint8_t a = *(pBmpData++);
// Draw the pixel
- ((UINT32 *)pBits)[x + y * width] =
- (a << 24) | (r << 16) | (g << 8) | b;
+ ((UINT32 *)pBits)[x + y * width] =
+ (a << 24) | (r << 16) | (g << 8) | b;
if( a > 0 )
{
int, int, BLENDFUNCTION );
AlphaBlend = ((Win32Factory*)OSFactory::instance( getIntf() ))->AlphaBlend;
if( AlphaBlend &&
- AlphaBlend( m_hDC, xDest, yDest, width, height, hDC, 0, 0,
- width, height, bf ) )
+ !AlphaBlend( m_hDC, xDest, yDest, width, height, hDC, 0, 0,
+ width, height, bf ) )
{
msg_Err( getIntf(), "AlphaBlend() failed" );
}
HRGN newMask = CreateRectRgn( left, top, left + width, top + height );
CombineRgn( m_mask, m_mask, newMask, RGN_OR );
SelectClipRgn( m_hDC, m_mask );
+ DeleteObject( newMask );
// Create a brush with the color
int red = (color & 0xff0000) >> 16;
r.right = left + width;
r.bottom = top + height;
FillRect( m_hDC, &r, hBrush );
+ DeleteObject( hBrush );
}
uint32_t color )
{
// Update the mask with the rectangle
- HRGN l1 = CreateRectRgn( left, top, left + width, top );
- HRGN l2 = CreateRectRgn( left + width, top, left + width, top + height );
- HRGN l3 = CreateRectRgn( left + width, top + height, left, top + height );
- HRGN l4 = CreateRectRgn( left, top + height, left, top );
+ HRGN l1 = CreateRectRgn( left, top, left + width, top + 1 );
+ HRGN l2 = CreateRectRgn( left + width - 1, top,
+ left + width, top + height );
+ HRGN l3 = CreateRectRgn( left, top + height - 1,
+ left + width, top + height );
+ HRGN l4 = CreateRectRgn( left, top, left + 1, top + height );
CombineRgn( m_mask, m_mask, l1, RGN_OR );
CombineRgn( m_mask, m_mask, l2, RGN_OR );
CombineRgn( m_mask, m_mask, l3, RGN_OR );
CombineRgn( m_mask, m_mask, l4, RGN_OR );
+ DeleteObject( l1 );
+ DeleteObject( l2 );
+ DeleteObject( l3 );
+ DeleteObject( l4 );
+
SelectClipRgn( m_hDC, m_mask );
// Create a pen with the color
bool Win32Graphics::hit( int x, int y ) const
{
- return PtInRegion( m_mask, x, y );
+ return PtInRegion( m_mask, x, y ) != 0;
}
void Win32Graphics::addSegmentInRegion( HRGN &rMask, int start,
int end, int line )
{
- HRGN buffer;
- buffer = CreateRectRgn( start, line, end, line + 1 );
+ HRGN buffer = CreateRectRgn( start, line, end, line + 1 );
CombineRgn( rMask, buffer, rMask, RGN_OR );
DeleteObject( buffer );
}