Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsimage.h File Reference
#include "vsfilesystem.h"

Go to the source code of this file.

Classes

struct  BITMAPINFOHEADER
 
struct  BITMAPFILEHEADER
 
struct  RGBQUAD
 
struct  pxlformat
 
struct  ddsHeader
 
struct  TPngFileBuffer
 
class  VSImage
 

Macros

#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
 
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT   0x83F1
 
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT   0x83F2
 
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT   0x83F3
 
#define GL_TEXTURE_COMPRESSION_HINT_ARB   0x84EF
 

Typedefs

typedef unsigned int DWORD
 
typedef int LONG
 
typedef unsigned short WORD
 
typedef unsigned char BYTE
 
typedef unsigned char *( textureTransform )(int &bpp, int &color_type, unsigned long &width, unsigned long &height, unsigned char **row_pointers)
 

Enumerations

enum  VSImageType {
  PngImage, BmpImage, JpegImage, DdsImage,
  Unrecognized
}
 

Functions

void png_write (const char *myfile, unsigned char *data, unsigned int width, unsigned int height, bool alpha, char bpp)
 

Variables

int PNG_HAS_PALETTE
 
int PNG_HAS_COLOR
 
int PNG_HAS_ALPHA
 
textureTransform heightmapTransform
 
textureTransform terrainTransform
 
textureTransform texTransform
 

Macro Definition Documentation

#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0

Definition at line 71 of file vsimage.h.

Referenced by GetTextureFormat(), and RGBCompressed().

#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT   0x83F1

Definition at line 74 of file vsimage.h.

Referenced by GetTextureFormat(), and RGBACompressed().

#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT   0x83F2

Definition at line 77 of file vsimage.h.

Referenced by GetTextureFormat(), and RGBACompressed().

#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT   0x83F3

Definition at line 80 of file vsimage.h.

Referenced by GetTextureFormat(), and RGBACompressed().

#define GL_TEXTURE_COMPRESSION_HINT_ARB   0x84EF

Definition at line 83 of file vsimage.h.

Typedef Documentation

typedef unsigned char BYTE

Definition at line 14 of file vsimage.h.

typedef unsigned int DWORD

Definition at line 11 of file vsimage.h.

typedef int LONG

Definition at line 12 of file vsimage.h.

typedef unsigned char*( textureTransform)(int &bpp, int &color_type, unsigned long &width, unsigned long &height, unsigned char **row_pointers)

Definition at line 117 of file vsimage.h.

typedef unsigned short WORD

Definition at line 13 of file vsimage.h.

Enumeration Type Documentation

Enumerator
PngImage 
BmpImage 
JpegImage 
DdsImage 
Unrecognized 

Definition at line 125 of file vsimage.h.

Function Documentation

void png_write ( const char *  myfile,
unsigned char *  data,
unsigned int  width,
unsigned int  height,
bool  alpha,
char  bpp 
)

Definition at line 128 of file bmp_to_png.cpp.

References height, i, VSFileSystem::vs_close(), VSFileSystem::vs_open(), and width.

Referenced by main().

129 {
130  FILE *fp = VSFileSystem::vs_open( myfile, "wb" );
131  png_structp png_ptr = png_create_write_struct
132  ( PNG_LIBPNG_VER_STRING, (png_voidp) NULL, NULL, NULL );
133  if (!png_ptr)
134  return;
135  png_infop info_ptr = png_create_info_struct( png_ptr );
136  if (!info_ptr) {
137  png_destroy_write_struct( &png_ptr, (png_infopp) NULL );
138  return;
139  }
140  if ( setjmp( png_ptr->jmpbuf ) ) {
141  png_destroy_write_struct( &png_ptr, &info_ptr );
143  return;
144  }
145  png_init_io( png_ptr, fp );
146  png_set_filter( png_ptr, 0, PNG_FILTER_NONE );
147  png_set_compression_level( png_ptr, Z_BEST_COMPRESSION );
148 
149  /* set other zlib parameters */
150  png_set_compression_mem_level( png_ptr, 8 );
151  png_set_compression_strategy( png_ptr, Z_DEFAULT_STRATEGY );
152  png_set_compression_window_bits( png_ptr, 15 );
153  png_set_compression_method( png_ptr, 8 );
154 
155  png_set_IHDR( png_ptr,
156  info_ptr,
157  width,
158  height,
159  bpp,
160  alpha ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
161  PNG_INTERLACE_NONE,
162  PNG_COMPRESSION_TYPE_DEFAULT,
163  PNG_FILTER_TYPE_DEFAULT );
164 
165  png_write_info( png_ptr, info_ptr );
166 # if __BYTE_ORDER != __BIG_ENDIAN
167  if (bpp == 16)
168  png_set_swap( png_ptr );
169 #endif
170  int stride = (bpp/8)*(alpha ? 4 : 3);
171  png_byte **row_pointers = new png_byte*[height];
172  for (unsigned int i = 0; i < height; i++)
173  row_pointers[i] = (png_byte*) &data[stride*i*width];
174  png_write_image( png_ptr, row_pointers );
175  png_write_end( png_ptr, info_ptr );
176  png_write_flush( png_ptr );
177  png_destroy_write_struct( &png_ptr, &info_ptr );
178 
180  free( data );
181  delete[] row_pointers;
182 }

Variable Documentation

textureTransform heightmapTransform

Definition at line 119 of file vsimage.h.

int PNG_HAS_ALPHA

Definition at line 58 of file vsimage.cpp.

Referenced by LoadTex(), and texTransform().

int PNG_HAS_COLOR

Definition at line 57 of file vsimage.cpp.

Referenced by LoadTex(), and texTransform().

int PNG_HAS_PALETTE

Definition at line 56 of file vsimage.cpp.

Referenced by texTransform().

textureTransform terrainTransform

Definition at line 120 of file vsimage.h.

textureTransform texTransform

Definition at line 121 of file vsimage.h.

Referenced by LoadTex().