Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 354551 | Differences between
and this patch

Collapse All | Expand All

(-)src/_png.cpp.old (-9 / +9 lines)
Lines 350-359 Link Here
350
    png_set_sig_bytes(png_ptr, 8);
350
    png_set_sig_bytes(png_ptr, 8);
351
    png_read_info(png_ptr, info_ptr);
351
    png_read_info(png_ptr, info_ptr);
352
352
353
    png_uint_32 width = info_ptr->width;
353
    png_uint_32 width, height;
354
    png_uint_32 height = info_ptr->height;
354
    int bit_depth, color_type;
355
355
356
    int bit_depth = info_ptr->bit_depth;
356
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL);
357
357
358
    // Unpack 1, 2, and 4-bit images
358
    // Unpack 1, 2, and 4-bit images
359
    if (bit_depth < 8)
359
    if (bit_depth < 8)
Lines 361-367 Link Here
361
361
362
    // If sig bits are set, shift data
362
    // If sig bits are set, shift data
363
    png_color_8p sig_bit;
363
    png_color_8p sig_bit;
364
    if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) &&
364
    if ((color_type != PNG_COLOR_TYPE_PALETTE) &&
365
        png_get_sBIT(png_ptr, info_ptr, &sig_bit))
365
        png_get_sBIT(png_ptr, info_ptr, &sig_bit))
366
    {
366
    {
367
        png_set_shift(png_ptr, sig_bit);
367
        png_set_shift(png_ptr, sig_bit);
Lines 374-386 Link Here
374
    }
374
    }
375
375
376
    // Convert palletes to full RGB
376
    // Convert palletes to full RGB
377
    if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
377
    if (color_type == PNG_COLOR_TYPE_PALETTE)
378
    {
378
    {
379
        png_set_palette_to_rgb(png_ptr);
379
        png_set_palette_to_rgb(png_ptr);
380
    }
380
    }
381
381
382
    // If there's an alpha channel convert gray to RGB
382
    // If there's an alpha channel convert gray to RGB
383
    if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
383
    if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
384
    {
384
    {
385
        png_set_gray_to_rgb(png_ptr);
385
        png_set_gray_to_rgb(png_ptr);
386
    }
386
    }
Lines 408-418 Link Here
408
    npy_intp dimensions[3];
408
    npy_intp dimensions[3];
409
    dimensions[0] = height;  //numrows
409
    dimensions[0] = height;  //numrows
410
    dimensions[1] = width;   //numcols
410
    dimensions[1] = width;   //numcols
411
    if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
411
    if (color_type & PNG_COLOR_MASK_ALPHA)
412
    {
412
    {
413
        dimensions[2] = 4;     //RGBA images
413
        dimensions[2] = 4;     //RGBA images
414
    }
414
    }
415
    else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
415
    else if (color_type & PNG_COLOR_MASK_COLOR)
416
    {
416
    {
417
        dimensions[2] = 3;     //RGB images
417
        dimensions[2] = 3;     //RGB images
418
    }
418
    }
Lines 421-427 Link Here
421
        dimensions[2] = 1;     //Greyscale images
421
        dimensions[2] = 1;     //Greyscale images
422
    }
422
    }
423
    //For gray, return an x by y array, not an x by y by 1
423
    //For gray, return an x by y array, not an x by y by 1
424
    int num_dims  = (info_ptr->color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;
424
    int num_dims  = (color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;
425
425
426
    double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
426
    double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
427
    PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(
427
    PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(

Return to bug 354551