~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to intern/cycles/render/image.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2011, Blender Foundation.
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
 
3
 *
 
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
 
7
 *
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
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
17
15
 */
18
16
 
19
17
#include "device.h"
129
127
 
130
128
                                is_linear = !(colorspace == "sRGB" ||
131
129
                                              colorspace == "GammaCorrected" ||
132
 
                                                          strcmp(in->format_name(), "png") == 0);
 
130
                                              (colorspace == "" &&
 
131
                                                  (strcmp(in->format_name(), "png") == 0 ||
 
132
                                                   strcmp(in->format_name(), "tiff") == 0 ||
 
133
                                                   strcmp(in->format_name(), "jpeg2000") == 0)));
133
134
                        }
134
 
                        else
 
135
                        else {
135
136
                                is_linear = false;
 
137
                        }
136
138
 
137
139
                        in->close();
138
140
                }
305
307
        }
306
308
 
307
309
        /* we only handle certain number of components */
308
 
        if(!(components == 1 || components == 3 || components == 4)) {
 
310
        if(!(components >= 1 && components <= 4)) {
309
311
                if(in) {
310
312
                        in->close();
311
313
                        delete in;
332
334
                builtin_image_pixels_cb(img->filename, img->builtin_data, pixels);
333
335
        }
334
336
 
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];
 
343
                }
 
344
        }
 
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);
389
399
        }
390
400
 
391
 
        if(!(components == 1 || components == 3 || components == 4)) {
 
401
        if(!(components >= 1 && components <= 4)) {
392
402
                if(in) {
393
403
                        in->close();
394
404
                        delete in;
414
424
                builtin_image_float_pixels_cb(img->filename, img->builtin_data, pixels);
415
425
        }
416
426
 
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];
 
433
                }
 
434
        }
 
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];