瀏覽代碼

* Changed the cucul_create_dither() prototype to make sure the mask

arguments are at least 32 bits.
tags/v0.99.beta14
Sam Hocevar sam 19 年之前
父節點
當前提交
d6e4744861
共有 2 個文件被更改,包括 10 次插入8 次删除
  1. +2
    -2
      cucul/cucul.h
  2. +8
    -6
      cucul/dither.c

+ 2
- 2
cucul/cucul.h 查看文件

@@ -163,8 +163,8 @@ int cucul_free_canvas_frame(cucul_canvas_t *, unsigned int);
* @{ */
cucul_dither_t *cucul_create_dither(unsigned int, unsigned int,
unsigned int, unsigned int,
unsigned int, unsigned int,
unsigned int, unsigned int);
unsigned long int, unsigned long int,
unsigned long int, unsigned long int);
int cucul_set_dither_palette(cucul_dither_t *,
unsigned int r[], unsigned int g[],
unsigned int b[], unsigned int a[]);


+ 8
- 6
cucul/dither.c 查看文件

@@ -164,7 +164,7 @@ struct cucul_dither
/*
* Local prototypes
*/
static void mask2shift(unsigned int, int *, int *);
static void mask2shift(unsigned long int, int *, int *);
static float gammapow(float x, float y);

static void get_rgba_default(cucul_dither_t const *, uint8_t *, int, int,
@@ -256,8 +256,10 @@ static inline void rgb2hsv_default(int r, int g, int b,
*/
cucul_dither_t *cucul_create_dither(unsigned int bpp, unsigned int w,
unsigned int h, unsigned int pitch,
unsigned int rmask, unsigned int gmask,
unsigned int bmask, unsigned int amask)
unsigned long int rmask,
unsigned long int gmask,
unsigned long int bmask,
unsigned long int amask)
{
cucul_dither_t *d;
int i;
@@ -1093,7 +1095,7 @@ int cucul_free_dither(cucul_dither_t *d)
*/

/* Convert a mask, eg. 0x0000ff00, to shift values, eg. 8 and -4. */
static void mask2shift(unsigned int mask, int *right, int *left)
static void mask2shift(unsigned long int mask, int *right, int *left)
{
int rshift = 0, lshift = 0;

@@ -1199,8 +1201,8 @@ static void get_rgba_default(cucul_dither_t const *d, uint8_t *pixels,
if(__BYTE_ORDER == __BIG_ENDIAN)
#else
/* This is compile-time optimised with at least -O1 or -Os */
uint32_t const rmask = 0x12345678;
if(*(uint8_t const *)&rmask == 0x12)
uint32_t const tmp = 0x12345678;
if(*(uint8_t const *)&tmp == 0x12)
#endif
bits = ((uint32_t)pixels[0] << 16) |
((uint32_t)pixels[1] << 8) |


Loading…
取消
儲存