Commit a8283ef6 authored by Cyril Deguet's avatar Cyril Deguet

* all : skeleton of a future bitmap font support

  * skin.dtd : new BitmapFont element
parent 7965c4dd
......@@ -79,12 +79,15 @@ SOURCES_skins2 = \
\
src/anchor.cpp \
src/anchor.hpp \
src/bitmap_font.cpp \
src/bitmap_font.hpp \
src/dialogs.cpp \
src/dialogs.hpp \
src/ft2_bitmap.cpp \
src/ft2_bitmap.hpp \
src/ft2_font.cpp \
src/ft2_font.hpp \
src/generic_bitmap.cpp \
src/generic_bitmap.hpp \
src/generic_font.hpp \
src/generic_layout.cpp \
......
/*****************************************************************************
* bitmap_font.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#include "bitmap_font.hpp"
#include "generic_bitmap.hpp"
BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap ):
GenericFont( pIntf ), m_rBitmap( rBitmap )
{
}
GenericBitmap *BitmapFont::drawString( const UString &rString,
uint32_t color, int maxWidth ) const
{
return NULL;
}
/*****************************************************************************
* bitmap_font.hpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#ifndef BITMAP_FONT_HPP
#define BITMAP_FONT_HPP
#include "generic_font.hpp"
class GenericBitmap;
/// Class to handle bitmap fonts
class BitmapFont: public GenericFont
{
public:
BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap );
virtual ~BitmapFont() {}
virtual bool init() { return true; }
/// Render a string on a bitmap.
/// If maxWidth != -1, the text is truncated with '...'
virtual GenericBitmap *drawString( const UString &rString,
uint32_t color, int maxWidth = -1 ) const;
/// Get the font size
virtual int getSize() const { return 12; }
private:
/// Bitmap
const GenericBitmap &m_rBitmap;
};
#endif
......@@ -2,7 +2,7 @@
* ft2_font.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ft2_font.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -47,9 +47,6 @@ class FT2Font: public GenericFont
/// Render a string on a bitmap.
/// If maxWidth != -1, the text is truncated with '...'
/// rAscent is filled with the maximum ascent of the glyphs in
/// the string (for explanations, see:
/// http://www.freetype.org/freetype2/docs/tutorial/step2.html)
virtual GenericBitmap *drawString( const UString &rString,
uint32_t color, int maxWidth = -1 ) const;
......
/*****************************************************************************
* generic_bitmap.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#include "generic_bitmap.hpp"
SubBitmap::SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
int left, int top, int width, int height ):
GenericBitmap( pIntf ), m_width( width ), m_height( height ),
m_pData( NULL )
{
m_pData = new uint8_t[width * height * 4];
uint32_t *pSrc = (uint32_t*)rSource.getData();
uint32_t *pDest = (uint32_t*)m_pData;
int srcWidth = rSource.getWidth();
for( int y = top; y < top + height; y++ )
{
memcpy( pDest, pSrc, 4 * width );
pSrc += srcWidth;
pDest += width;
}
}
SubBitmap::~SubBitmap()
{
delete[] m_pData;
}
......@@ -2,7 +2,7 @@
* generic_bitmap.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic_bitmap.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -29,7 +29,7 @@
#include "../utils/pointer.hpp"
/// base class for bitmaps
/// Base class for bitmaps
class GenericBitmap: public SkinObject
{
public:
......@@ -49,6 +49,33 @@ class GenericBitmap: public SkinObject
GenericBitmap( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
};
/// Bitmap created from a region of another bitmap
class SubBitmap: public GenericBitmap
{
public:
SubBitmap( intf_thread_t *pIntf, const GenericBitmap &rSource,
int left, int top, int width, int height );
~SubBitmap();
/// Get the width of the bitmap
virtual int getWidth() const { return m_width; }
/// Get the heighth of the bitmap
virtual int getHeight() const { return m_height; }
/// Get a linear buffer containing the image data.
/// Each pixel is stored in 4 bytes in the order B,G,R,A
virtual uint8_t *getData() const { return m_pData; }
private:
/// Size of the bitmap.
int m_width, m_height;
/// Buffer containing the image data.
uint8_t *m_pData;
};
typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
#endif
......@@ -2,7 +2,7 @@
* generic_font.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic_font.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -41,13 +41,10 @@ class GenericFont: public SkinObject
/// Render a string on a bitmap.
/// If maxWidth != -1, the text is truncated with '...'
/// rAscent is filled with the maximum ascent of the glyphs in
/// the string (for explanations, see:
/// http://www.freetype.org/freetype2/docs/tutorial/step2.html)
/// The Bitmap is _not_ owned by this object
virtual GenericBitmap *drawString( const UString &rString,
uint32_t color, int maxWidth = -1 ) const = 0;
/// Get the font size
virtual int getSize() const = 0;
......
......@@ -28,6 +28,12 @@
italic CDATA "false"
underline CDATA "false"
>
<!ELEMENT BitmapFont EMPTY>
<!ATTLIST Font
id CDATA #REQUIRED
file CDATA #REQUIRED
type CDATA "digits"
>
<!ELEMENT ThemeInfo EMPTY>
<!ATTLIST ThemeInfo
name CDATA #IMPLIED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment