1999-12-15 17:38:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-10-30 06:56:12 -05:00
|
|
|
// Name: wx/imagbmp.h
|
2006-10-09 13:51:07 -04:00
|
|
|
// Purpose: wxImage BMP, ICO, CUR and ANI handlers
|
2002-01-01 18:13:02 -05:00
|
|
|
// Author: Robert Roebling, Chris Elliott
|
|
|
|
// Copyright: (c) Robert Roebling, Chris Elliott
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-12-15 17:38:02 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_IMAGBMP_H_
|
|
|
|
#define _WX_IMAGBMP_H_
|
|
|
|
|
|
|
|
#include "wx/image.h"
|
|
|
|
|
2001-08-25 11:30:49 -04:00
|
|
|
// defines for saving the BMP file in different formats, Bits Per Pixel
|
2002-02-15 20:45:30 -05:00
|
|
|
// USE: wximage.SetOption( wxIMAGE_OPTION_BMP_FORMAT, wxBMP_xBPP );
|
2009-07-23 16:30:22 -04:00
|
|
|
#define wxIMAGE_OPTION_BMP_FORMAT wxString(wxT("wxBMP_FORMAT"))
|
2002-02-15 20:45:30 -05:00
|
|
|
|
|
|
|
// These two options are filled in upon reading CUR file and can (should) be
|
|
|
|
// specified when saving a CUR file - they define the hotspot of the cursor:
|
|
|
|
#define wxIMAGE_OPTION_CUR_HOTSPOT_X wxT("HotSpotX")
|
|
|
|
#define wxIMAGE_OPTION_CUR_HOTSPOT_Y wxT("HotSpotY")
|
|
|
|
|
2001-08-25 11:30:49 -04:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxBMP_24BPP = 24, // default, do not need to set
|
|
|
|
//wxBMP_16BPP = 16, // wxQuantize can only do 236 colors?
|
|
|
|
wxBMP_8BPP = 8, // 8bpp, quantized colors
|
|
|
|
wxBMP_8BPP_GREY = 9, // 8bpp, rgb averaged to greys
|
|
|
|
wxBMP_8BPP_GRAY = wxBMP_8BPP_GREY,
|
|
|
|
wxBMP_8BPP_RED = 10, // 8bpp, red used as greyscale
|
|
|
|
wxBMP_8BPP_PALETTE = 11, // 8bpp, use the wxImage's palette
|
|
|
|
wxBMP_4BPP = 4, // 4bpp, quantized colors
|
|
|
|
wxBMP_1BPP = 1, // 1bpp, quantized "colors"
|
|
|
|
wxBMP_1BPP_BW = 2 // 1bpp, black & white from red
|
|
|
|
};
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
1999-12-15 17:38:02 -05:00
|
|
|
// wxBMPHandler
|
2000-07-15 15:51:35 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
1999-12-15 17:38:02 -05:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxBMPHandler : public wxImageHandler
|
1999-12-15 17:38:02 -05:00
|
|
|
{
|
|
|
|
public:
|
2001-11-18 04:43:06 -05:00
|
|
|
wxBMPHandler()
|
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
m_name = wxT("Windows bitmap file");
|
|
|
|
m_extension = wxT("bmp");
|
2001-11-18 04:43:06 -05:00
|
|
|
m_type = wxBITMAP_TYPE_BMP;
|
2009-07-23 16:30:22 -04:00
|
|
|
m_mime = wxT("image/x-bmp");
|
2007-04-14 05:58:37 -04:00
|
|
|
}
|
1999-12-15 17:38:02 -05:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ) wxOVERRIDE;
|
|
|
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ) wxOVERRIDE;
|
2002-02-07 13:46:31 -05:00
|
|
|
|
2001-11-18 04:43:06 -05:00
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoCanRead( wxInputStream& stream ) wxOVERRIDE;
|
2002-02-07 13:46:31 -05:00
|
|
|
bool SaveDib(wxImage *image, wxOutputStream& stream, bool verbose,
|
2002-01-01 18:13:02 -05:00
|
|
|
bool IsBmp, bool IsMask);
|
2002-02-07 13:46:31 -05:00
|
|
|
bool DoLoadDib(wxImage *image, int width, int height, int bpp, int ncolors,
|
2004-10-18 01:56:07 -04:00
|
|
|
int comp, wxFileOffset bmpOffset, wxInputStream& stream,
|
2014-03-13 21:36:54 -04:00
|
|
|
bool verbose, bool IsBmp, bool hasPalette, int colEntrySize = 4);
|
2002-01-01 18:13:02 -05:00
|
|
|
bool LoadDib(wxImage *image, wxInputStream& stream, bool verbose, bool IsBmp);
|
2001-11-18 04:43:06 -05:00
|
|
|
#endif // wxUSE_STREAMS
|
2000-07-15 15:51:35 -04:00
|
|
|
|
2001-11-18 04:43:06 -05:00
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxBMPHandler);
|
2001-11-18 04:43:06 -05:00
|
|
|
};
|
|
|
|
|
2002-01-13 07:01:42 -05:00
|
|
|
#if wxUSE_ICO_CUR
|
2001-11-18 04:43:06 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxICOHandler
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxICOHandler : public wxBMPHandler
|
2001-11-18 04:43:06 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxICOHandler()
|
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
m_name = wxT("Windows icon file");
|
|
|
|
m_extension = wxT("ico");
|
2001-11-18 04:43:06 -05:00
|
|
|
m_type = wxBITMAP_TYPE_ICO;
|
2009-07-23 16:30:22 -04:00
|
|
|
m_mime = wxT("image/x-ico");
|
2007-04-14 05:58:37 -04:00
|
|
|
}
|
2001-11-18 04:43:06 -05:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=true ) wxOVERRIDE;
|
|
|
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ) wxOVERRIDE;
|
2002-01-13 07:01:42 -05:00
|
|
|
virtual bool DoLoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index );
|
2009-08-21 06:41:26 -04:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int DoGetImageCount( wxInputStream& stream ) wxOVERRIDE;
|
|
|
|
virtual bool DoCanRead( wxInputStream& stream ) wxOVERRIDE;
|
2000-07-15 15:51:35 -04:00
|
|
|
#endif // wxUSE_STREAMS
|
|
|
|
|
2001-11-18 04:43:06 -05:00
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxICOHandler);
|
1999-12-15 17:38:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-01-01 18:13:02 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCURHandler
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxCURHandler : public wxICOHandler
|
2002-01-01 18:13:02 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxCURHandler()
|
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
m_name = wxT("Windows cursor file");
|
|
|
|
m_extension = wxT("cur");
|
2002-01-01 18:13:02 -05:00
|
|
|
m_type = wxBITMAP_TYPE_CUR;
|
2009-07-23 16:30:22 -04:00
|
|
|
m_mime = wxT("image/x-cur");
|
2007-04-14 05:58:37 -04:00
|
|
|
}
|
2002-02-07 13:46:31 -05:00
|
|
|
|
2002-01-01 18:13:02 -05:00
|
|
|
// VS: This handler's meat is implemented inside wxICOHandler (the two
|
|
|
|
// formats are almost identical), but we hide this fact at
|
|
|
|
// the API level, since it is a mere implementation detail.
|
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2002-01-01 18:13:02 -05:00
|
|
|
#if wxUSE_STREAMS
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoCanRead( wxInputStream& stream ) wxOVERRIDE;
|
2002-01-01 18:13:02 -05:00
|
|
|
#endif // wxUSE_STREAMS
|
|
|
|
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxCURHandler);
|
2002-01-01 18:13:02 -05:00
|
|
|
};
|
2002-01-13 07:01:42 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxANIHandler
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxANIHandler : public wxCURHandler
|
2002-01-13 07:01:42 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxANIHandler()
|
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
m_name = wxT("Windows animated cursor file");
|
|
|
|
m_extension = wxT("ani");
|
2002-01-13 07:01:42 -05:00
|
|
|
m_type = wxBITMAP_TYPE_ANI;
|
2009-07-23 16:30:22 -04:00
|
|
|
m_mime = wxT("image/x-ani");
|
2007-04-14 05:58:37 -04:00
|
|
|
}
|
2002-02-07 13:46:31 -05:00
|
|
|
|
2002-01-13 07:01:42 -05:00
|
|
|
|
|
|
|
#if wxUSE_STREAMS
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose=true) ) wxOVERRIDE{return false ;}
|
|
|
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=true, int index=-1 ) wxOVERRIDE;
|
2009-06-01 07:43:36 -04:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int DoGetImageCount( wxInputStream& stream ) wxOVERRIDE;
|
|
|
|
virtual bool DoCanRead( wxInputStream& stream ) wxOVERRIDE;
|
2002-01-13 07:01:42 -05:00
|
|
|
#endif // wxUSE_STREAMS
|
|
|
|
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxANIHandler);
|
2002-01-13 07:01:42 -05:00
|
|
|
};
|
1999-12-15 17:38:02 -05:00
|
|
|
|
2002-01-13 07:01:42 -05:00
|
|
|
#endif // wxUSE_ICO_CUR
|
2002-01-01 18:13:02 -05:00
|
|
|
#endif // _WX_IMAGBMP_H_
|