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 / +10 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-392 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
    }
387
387
388
    png_set_interlace_handling(png_ptr);
388
    png_set_interlace_handling(png_ptr);
389
    png_read_update_info(png_ptr, info_ptr);
389
    png_read_update_info(png_ptr, info_ptr);
390
    color_type = png_get_color_type(png_ptr, info_ptr);
390
391
391
    /* read file */
392
    /* read file */
392
    if (setjmp(png_jmpbuf(png_ptr)))
393
    if (setjmp(png_jmpbuf(png_ptr)))
Lines 408-418 Link Here
408
    npy_intp dimensions[3];
409
    npy_intp dimensions[3];
409
    dimensions[0] = height;  //numrows
410
    dimensions[0] = height;  //numrows
410
    dimensions[1] = width;   //numcols
411
    dimensions[1] = width;   //numcols
411
    if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
412
    if (color_type & PNG_COLOR_MASK_ALPHA)
412
    {
413
    {
413
        dimensions[2] = 4;     //RGBA images
414
        dimensions[2] = 4;     //RGBA images
414
    }
415
    }
415
    else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
416
    else if (color_type & PNG_COLOR_MASK_COLOR)
416
    {
417
    {
417
        dimensions[2] = 3;     //RGB images
418
        dimensions[2] = 3;     //RGB images
418
    }
419
    }
Lines 421-427 Link Here
421
        dimensions[2] = 1;     //Greyscale images
422
        dimensions[2] = 1;     //Greyscale images
422
    }
423
    }
423
    //For gray, return an x by y array, not an x by y by 1
424
    //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;
425
    int num_dims  = (color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;
425
426
426
    double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
427
    double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
427
    PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(
428
    PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(

Return to bug 354551