#include "vsimage.h"
#include <png.h>
Go to the source code of this file.
|
unsigned char * | texTransform (int &bpp, int &color_type, unsigned long &width, unsigned long &height, unsigned char **rp) |
|
unsigned char * | heightmapTransform (int &bpp, int &color_type, unsigned long &width, unsigned long &height, unsigned char **row_pointers) |
|
unsigned char * | terrainTransform (int &bpp, int &color_type, unsigned long &width, unsigned long &height, unsigned char **row_pointers) |
|
unsigned char* heightmapTransform |
( |
int & |
bpp, |
|
|
int & |
color_type, |
|
|
unsigned long & |
width, |
|
|
unsigned long & |
height, |
|
|
unsigned char ** |
row_pointers |
|
) |
| |
16 bit colors...take Red
Definition at line 20 of file tex_transform.cpp.
References coloffset, height, i, j, VsnetOSS::memcpy(), and width.
26 unsigned short *dat = (
unsigned short*) malloc(
sizeof (
unsigned short)*
width*
height );
27 if ( (bpp == 8 && color_type
28 == PNG_COLOR_TYPE_RGB_ALPHA) || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) {
29 if (bpp == 8 && color_type == PNG_COLOR_TYPE_GRAY) {
30 for (
unsigned int i = 0;
i <
height;
i++) {
31 unsigned long iwid =
i*
width;
32 for (
unsigned int j = 0;
j <
width;
j++)
33 dat[iwid+j] = row_pointers[i][j];
36 if ( (bpp == 16 && color_type == PNG_COLOR_TYPE_GRAY) || (bpp == 8 && color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ) {
37 for (
unsigned int i = 0;
i <
height;
i++)
41 for (
unsigned int i = 0; i <
height; i++) {
42 unsigned long iwid = i*
width;
43 for (
unsigned int j = 0;
j <
width;
j++)
44 dat[iwid+j] = ( ( (
unsigned short*) row_pointers[i] )[j*2] );
49 if (color_type == PNG_COLOR_TYPE_RGB) {
50 unsigned int coloffset = (bpp == 8) ? 3 : 6;
51 for (
unsigned int i = 0; i <
height; i++) {
52 unsigned long iwid = i*
width;
53 for (
unsigned int j = 0;
j <
width;
j++)
54 dat[iwid+j] = *( (
unsigned short*) ( &(row_pointers[i][
j*
coloffset]) ) );
56 }
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
58 for (
unsigned int i = 0; i <
height; i++) {
59 unsigned long iwid = i*
width;
60 for (
unsigned int j = 0;
j <
width;
j++)
61 dat[iwid+j] = ( ( (
unsigned short*) row_pointers[i] )[j*4] );
66 color_type = PNG_COLOR_TYPE_GRAY;
67 return (
unsigned char*) dat;
unsigned char* terrainTransform |
( |
int & |
bpp, |
|
|
int & |
color_type, |
|
|
unsigned long & |
width, |
|
|
unsigned long & |
height, |
|
|
unsigned char ** |
row_pointers |
|
) |
| |
16 bit colors...take Red
Definition at line 70 of file tex_transform.cpp.
References coloffset, height, i, j, VsnetOSS::memcpy(), and width.
76 unsigned char *dat = (
unsigned char*) malloc(
sizeof (
unsigned char)*
width*
height );
77 if ( (bpp == 8 && color_type
78 == PNG_COLOR_TYPE_RGB_ALPHA) || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA ) {
79 if (bpp == 8 && color_type == PNG_COLOR_TYPE_GRAY) {
80 for (
unsigned int i = 0;
i <
height;
i++)
83 if ( (bpp == 16 && color_type == PNG_COLOR_TYPE_GRAY) || (bpp == 8 && color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ) {
84 for (
unsigned int i = 0; i <
height; i++) {
85 unsigned long iwid = i*
width;
86 for (
unsigned int j = 0;
j <
width;
j++)
87 dat[iwid+j] = (row_pointers[i])[
j*2];
91 for (
unsigned int i = 0; i <
height; i++) {
92 unsigned long iwid = i*
width;
93 for (
unsigned int j = 0;
j <
width;
j++)
94 dat[iwid+j] = ( (row_pointers[i])[
j*4] );
99 if (color_type == PNG_COLOR_TYPE_RGB) {
100 unsigned int coloffset = (bpp == 8) ? 3 : 6;
101 for (
unsigned int i = 0; i <
height; i++) {
102 unsigned long iwid = i*
width;
103 for (
unsigned int j = 0;
j <
width;
j++)
104 dat[iwid+j] = *( (
unsigned char*) ( &(row_pointers[i][
j*
coloffset]) ) );
106 }
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
108 for (
unsigned int i = 0; i <
height; i++) {
109 unsigned long iwid = i*
width;
110 for (
unsigned int j = 0;
j <
width;
j++)
111 dat[iwid+j] = ( ( (
unsigned short*) row_pointers[i] )[j*4] )/256;
116 color_type = PNG_COLOR_TYPE_GRAY;
118 return (
unsigned char*) dat;
unsigned char* texTransform |
( |
int & |
bpp, |
|
|
int & |
color_type, |
|
|
unsigned long & |
width, |
|
|
unsigned long & |
height, |
|
|
unsigned char ** |
rp |
|
) |
| |