Files
libimg/src/utils.c
T

39 lines
1.1 KiB
C

#include "image/utils.h"
#include <stdio.h>
unsigned long
u32to_u64(const unsigned int clr)
{
unsigned long mask = 0;
unsigned long alpha = DECODE_A(clr);
unsigned long red = DECODE_R(clr);
unsigned long green = DECODE_G(clr);
unsigned long blue = DECODE_B(clr);
return (alpha << 48) | (red << 32) | (green << 16) | (blue);
}
unsigned int
u64to_u32(const unsigned long clr, const unsigned long u64_div)
{
unsigned int a = ((clr >> 48) & LONG_BYTE);
unsigned int r = ((clr >> 32) & LONG_BYTE);
unsigned int g = ((clr >> 16) & LONG_BYTE);
unsigned int b = (clr & LONG_BYTE);
return ENCODE_ARGB((a / u64_div), (r / u64_div), (g / u64_div),
(b / u64_div));
}
void
__attribute__((overloadable))
print_attr(const PPM *src) {
printf("Name: %s\nFMT: %c\nWidth: %i, Height: %i\nLength: %i\n",
src->name, src->fmt, src->width, src->height, src->len);
}
void
__attribute__((overloadable))
print_attr(const JPEG *src) {
printf("Name: %s\nWidth: %i, Height: %i\nLength: %i\n",
src->name, src->width, src->height, src->len);
}