OLD | NEW |
1 /* | 1 /* |
2 * $Id$ | 2 * $Id$ |
3 * | 3 * |
4 * ***** BEGIN GPL LICENSE BLOCK ***** | 4 * ***** BEGIN GPL LICENSE BLOCK ***** |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or | 6 * This program is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License | 7 * modify it under the terms of the GNU General Public License |
8 * as published by the Free Software Foundation; either version 2 | 8 * as published by the Free Software Foundation; either version 2 |
9 * of the License, or (at your option) any later version. | 9 * of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bits_per_pixel = 32; | 118 bits_per_pixel = 32; |
119 break; | 119 break; |
120 }; | 120 }; |
121 }; | 121 }; |
122 }; | 122 }; |
123 ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);· | 123 ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);· |
124 if (ibuf == 0) return(0); /* memory allocation failed */ | 124 if (ibuf == 0) return(0); /* memory allocation failed */ |
125 | 125 |
126 ibuf->ftype = DDS; | 126 ibuf->ftype = DDS; |
127 ibuf->profile = IB_PROFILE_SRGB; | 127 ibuf->profile = IB_PROFILE_SRGB; |
| 128 ibuf->dds_data.fourcc = dds.fourCC(); |
| 129 ibuf->dds_data.nummipmaps = dds.mipmapCount(); |
128 | 130 |
129 if ((flags & IB_test) == 0) { | 131 if ((flags & IB_test) == 0) { |
130 if (!imb_addrectImBuf(ibuf)) return(ibuf); | 132 if (!imb_addrectImBuf(ibuf)) return(ibuf); |
131 if (ibuf->rect == 0) return(ibuf); | 133 if (ibuf->rect == 0) return(ibuf); |
132 | 134 |
133 rect = ibuf->rect; | 135 rect = ibuf->rect; |
134 cp[3] = 0xff; /* default alpha if alpha channel is not present *
/ | 136 cp[3] = 0xff; /* default alpha if alpha channel is not present *
/ |
135 | 137 |
136 for (unsigned int i = 0; i < numpixels; i++) { | 138 for (unsigned int i = 0; i < numpixels; i++) { |
137 pixel = pixels[i]; | 139 pixel = pixels[i]; |
138 cp[0] = pixel.r; /* set R component of col */ | 140 cp[0] = pixel.r; /* set R component of col */ |
139 cp[1] = pixel.g; /* set G component of col */ | 141 cp[1] = pixel.g; /* set G component of col */ |
140 cp[2] = pixel.b; /* set B component of col */ | 142 cp[2] = pixel.b; /* set B component of col */ |
141 » » » if (bits_per_pixel == 32) | 143 » » » if (dds.hasAlpha()) |
142 cp[3] = pixel.a; /* set A component of col */ | 144 cp[3] = pixel.a; /* set A component of col */ |
143 rect[i] = col; | 145 rect[i] = col; |
144 } | 146 } |
| 147 |
| 148 if (ibuf->dds_data.fourcc != FOURCC_DDS) |
| 149 ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf-
>dds_data.size); |
| 150 else { |
| 151 ibuf->dds_data.data = NULL; |
| 152 ibuf->dds_data.size = 0; |
| 153 } |
| 154 |
145 IMB_flipy(ibuf); | 155 IMB_flipy(ibuf); |
146 } | 156 } |
147 | 157 |
148 return(ibuf); | 158 return(ibuf); |
149 } | 159 } |
150 | 160 |
151 } // extern "C" | 161 } // extern "C" |
OLD | NEW |