2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2
* Copyright 2011-2013 Blender Foundation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License
19
17
#include "device.h"
130
128
is_linear = !(colorspace == "sRGB" ||
131
129
colorspace == "GammaCorrected" ||
132
strcmp(in->format_name(), "png") == 0);
131
(strcmp(in->format_name(), "png") == 0 ||
132
strcmp(in->format_name(), "tiff") == 0 ||
133
strcmp(in->format_name(), "jpeg2000") == 0)));
135
136
is_linear = false;
332
334
builtin_image_pixels_cb(img->filename, img->builtin_data, pixels);
335
if(components == 3) {
337
if(components == 2) {
338
for(int i = width*height-1; i >= 0; i--) {
339
pixels[i*4+3] = pixels[i*2+1];
340
pixels[i*4+2] = pixels[i*2+0];
341
pixels[i*4+1] = pixels[i*2+0];
342
pixels[i*4+0] = pixels[i*2+0];
345
else if(components == 3) {
336
346
for(int i = width*height-1; i >= 0; i--) {
337
347
pixels[i*4+3] = 255;
338
348
pixels[i*4+2] = pixels[i*3+2];
388
398
builtin_image_info_cb(img->filename, img->builtin_data, is_float, width, height, components);
391
if(!(components == 1 || components == 3 || components == 4)) {
401
if(!(components >= 1 && components <= 4)) {
414
424
builtin_image_float_pixels_cb(img->filename, img->builtin_data, pixels);
417
if(components == 3) {
427
if(components == 2) {
428
for(int i = width*height-1; i >= 0; i--) {
429
pixels[i*4+3] = pixels[i*2+1];
430
pixels[i*4+2] = pixels[i*2+0];
431
pixels[i*4+1] = pixels[i*2+0];
432
pixels[i*4+0] = pixels[i*2+0];
435
else if(components == 3) {
418
436
for(int i = width*height-1; i >= 0; i--) {
419
437
pixels[i*4+3] = 1.0f;
420
438
pixels[i*4+2] = pixels[i*3+2];