Changeset 4737


Ignore:
Timestamp:
Feb 1, 2011, 9:04:25 PM (9 years ago)
Author:
Sam Hocevar
Message:

Reactivate pipi_dither_24to16, it's wrong but useful.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/dither.c

    r2902 r4737  
    2626#include "pipi_internals.h"
    2727
     28/* FIXME: this is not the right place for this... see pixels.c instead */
    2829void pipi_dither_24to16(pipi_image_t *img)
    2930{
    30 /* XXX: disabled because this is not the right place... see pixels.c instead */
    31 #if 0
    3231    int *error, *nexterror;
     32    pipi_pixels_t *p;
    3333    uint32_t *p32;
    3434    int x, y;
    3535
    36     error = malloc(sizeof(int) * 3 * (img->width + 2));
    37     nexterror = malloc(sizeof(int) * 3 * (img->width + 2));
    38     p32 = (uint32_t *)img->pixels;
     36    error = malloc(sizeof(int) * 3 * (img->w + 2));
     37    nexterror = malloc(sizeof(int) * 3 * (img->w + 2));
     38    p = pipi_get_pixels(img, PIPI_PIXELS_RGBA_U8);
     39    p32 = (uint32_t *)p->pixels;
    3940
    40     memset(error, 0, sizeof(int) * 3 * (img->width + 2));
     41    memset(error, 0, sizeof(int) * 3 * (img->w + 2));
    4142
    42     for(y = 0; y < img->height; y++)
     43    for(y = 0; y < img->h; y++)
    4344    {
    4445        int er = 0, eg = 0, eb = 0;
    4546
    46         memset(nexterror, 0, sizeof(int) * 3 * (img->width + 2));
     47        memset(nexterror, 0, sizeof(int) * 3 * (img->w + 2));
    4748
    48         for(x = 0; x < img->width; x++)
     49        for(x = 0; x < img->w; x++)
    4950        {
    50             int r, g, b, r2, g2, b2;
    51             r = p32[y * img->width + x] & 0xff;
    52             g = (p32[y * img->width + x] >> 8) & 0xff;
    53             b = (p32[y * img->width + x] >> 16) & 0xff;
     51            int r, g, b, a, r2, g2, b2;
     52            r = p32[y * img->w + x] & 0xff;
     53            g = (p32[y * img->w + x] >> 8) & 0xff;
     54            b = (p32[y * img->w + x] >> 16) & 0xff;
     55            a = (p32[y * img->w + x] >> 24) & 0xff;
    5456            r += er + error[x * 3 + 3];
    5557            g += eg + error[x * 3 + 4];
     
    6264            if(r2 == 0x88 && g2 == 0x88 && b2 == 0x88) g2 = 0x84;
    6365            /* hack */
    64             p32[y * img->width + x] = (b2 << 16) | (g2 << 8)  | r2;
     66            p32[y * img->w + x] = (a << 24) | (b2 << 16) | (g2 << 8)  | r2;
    6567
    6668            er = r - (r2 / 8 * 255 / 31);
     
    8183        }
    8284
    83         memcpy(error, nexterror, sizeof(int) * 3 * (img->width + 2));
     85        memcpy(error, nexterror, sizeof(int) * 3 * (img->w + 2));
    8486    }
     87
     88    pipi_release_pixels(img, p);
    8589
    8690    free(error);
    8791    free(nexterror);
    88 #endif
    8992}
    9093
Note: See TracChangeset for help on using the changeset viewer.