📄 targa_provider_generic.h
字号:
/* $Id: targa_provider_generic.h,v 1.9 2003/10/14 15:52:12 mbn Exp $
**
** ClanLib Game SDK
** Copyright (C) 2003 The ClanLib Team
** For a total list of contributers see the file CREDITS.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef header_targaprovider_generic
#define header_targaprovider_generic
#if _MSC_VER > 1000
#pragma once
#endif
#include "API/Display/Providers/targa_provider.h"
#include "Display/pixel_buffer_generic.h"
#include "API/Core/IOData/inputsource.h"
#include "API/Core/IOData/inputsource_provider.h"
//: Surface provider that can load targa (.tga) files.
class CL_TargaProvider_Generic : public CL_PixelBuffer_Generic
{
//! Construction:
public:
//: Constructs a surface provider that can read targa files.
//param name: Name of the targa file to load.
//param provider: Input source provider that delivers the targa file.
//param transparent: True if a transparency color should be used.
//param ignore_alphachannel: True if the alpha component should be ignored.
//param trans_red: Red component of the transparency color.
//param trans_green: Green component of the transparency color.
//param trans_blue: blue component of the transparency color.
CL_TargaProvider_Generic(
const std::string name,
CL_InputSourceProvider *provider,
bool transparent=false,
bool ignore_alphachannel=false,
unsigned char trans_red=0,
unsigned char trans_green=0,
unsigned char trans_blue=0);
//: Target Provider Destructor
virtual ~CL_TargaProvider_Generic();
//! Attributes:
//: Returns the pitch of the image (bytes per line).
unsigned int get_pitch() const { return pitch*4; }
//: Returns the width of the image.
unsigned int get_width() const { return bounding_right-bounding_left+1; }
//: Returns the height of the image.
unsigned int get_height() const { return bounding_bottom-bounding_top+1; }
//: Returns the number of subsprites in the image.
unsigned int get_num_frames() const { return no_sprs; }
//: Returns the pixelformat used by the image.
unsigned int get_depth() const { return 32; }
//: Get red mask
unsigned int get_red_mask() const { return 0xff000000; }
//: Get green mask
unsigned int get_green_mask() const { return 0x00ff0000; }
//: Get blue mask
unsigned int get_blue_mask() const { return 0x0000ff00; }
//: Get alpha mask
unsigned int get_alpha_mask() const { if ((!transparent) && (ignore_alphachannel)) return 0x0; else return 0x000000ff; }
//: Is indexed
bool is_indexed() const { return false; }
//: Uses src colour key
bool uses_src_colorkey() const { return trans_col != -1; }
//: Returns the transparency color used, -1 if none.
unsigned int get_src_colorkey() const { return trans_col; }
//! Operations:
public:
//: Returns the image data. Provider must be locked before pointer is valid.
virtual void *get_data();
//: Locks the surface provider.
virtual void perform_lock();
//: Unlocks the surface provider.
virtual void perform_unlock();
//! Implementation:
private:
std::string filename;
bool locked;
unsigned char *file;
int filesize;
unsigned char *image;
unsigned short map_length;
unsigned char *color_map;
unsigned char datatype;
int pitch, height, no_sprs, trans_col;
int bounding_left, bounding_top, bounding_right, bounding_bottom;
int map_direction_x, map_direction_y;
unsigned char bpp;
bool transparent, ignore_alphachannel, use_alphapixels;
unsigned char trans_redcol, trans_greencol, trans_bluecol;
int pos;
//: returns true if non-transparent pixel read
inline bool read_rgb_16(
unsigned char *a,
unsigned char *b,
unsigned char *g,
unsigned char *r);
inline bool read_rgb_24(
unsigned char *a,
unsigned char *b,
unsigned char *g,
unsigned char *r);
inline bool read_rgb_32(
unsigned char *a,
unsigned char *b,
unsigned char *g,
unsigned char *r);
inline bool read_rgb(
unsigned char *a,
unsigned char *b,
unsigned char *g,
unsigned char *r);
void read_from_colormap(unsigned char *a,
unsigned char *b,
unsigned char *g,
unsigned char *r);
void read_data();
void read_header(bool read_colormap);
void read_colormapped();
void read_uncompressed_rgb();
void read_runlength_encoded_colormapped_rgb();
void read_runlength_encoded_rgb();
CL_InputSourceProvider *provider;
CL_InputSource *input_source;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -