#undef LOCAL_DEBUG
-#include "lib/lib.h"
-#include "images/images.h"
-#include "images/color.h"
-#include "images/error.h"
-#include "images/math.h"
+#include <ucw/lib.h>
+#include <ucw/time.h>
+#include <images/images.h>
+#include <images/color.h>
+#include <images/error.h>
+#include <images/math.h>
#include <string.h>
#include <math.h>
struct image_conv_options image_conv_defaults = {
.flags = IMAGE_CONV_COPY_ALPHA | IMAGE_CONV_FILL_ALPHA | IMAGE_CONV_APPLY_ALPHA,
.background = { .color_space = COLOR_SPACE_GRAYSCALE } };
-
+
/* Grayscale <-> RGB */
#define IMAGE_WALK_PREFIX(x) walk_##x
#define IMAGE_WALK_SEC_COL_STEP 1
#define IMAGE_WALK_UNROLL 4
#define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_pos[1] = walk_pos[2] = walk_sec_pos[0]; }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
#define IMAGE_WALK_PREFIX(x) walk_##x
#define IMAGE_WALK_FUNC_NAME image_conv_rgb_n_to_gray_1
#define IMAGE_WALK_COL_STEP 1
#define IMAGE_WALK_UNROLL 2
#define IMAGE_WALK_DO_STEP do{ walk_pos[0] = rgb_to_gray_func(walk_sec_pos[0], walk_sec_pos[1], walk_sec_pos[2]); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
+
+/* Grayscale <-> YCbCr */
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_gray_1_to_ycbcr_n
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_SEC_COL_STEP 1
+#define IMAGE_WALK_UNROLL 4
+#define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; walk_pos[1] = walk_pos[2] = 0; }while(0)
+#include <images/image-walk.h>
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_ycbcr_n_to_gray_1
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_COL_STEP 1
+#define IMAGE_WALK_UNROLL 4
+#define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; }while(0)
+#include <images/image-walk.h>
/* YCbCr <-> RGB */
#define IMAGE_WALK_FUNC_NAME image_conv_ycbcr_n_to_rgb_n
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_DO_STEP do{ pixel_conv_ycbcr_to_rgb(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
static inline void
pixel_conv_rgb_to_ycbcr(byte *dest, byte *src)
#define IMAGE_WALK_FUNC_NAME image_conv_rgb_n_to_ycbcr_n
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_DO_STEP do{ pixel_conv_rgb_to_ycbcr(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
/* CMYK <-> RGB */
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_SEC_COL_STEP 4
#define IMAGE_WALK_DO_STEP do{ pixel_conv_cmyk_to_rgb(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
static inline void
pixel_conv_rgb_to_cmyk(byte *dest, byte *src)
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_COL_STEP 4
#define IMAGE_WALK_DO_STEP do{ pixel_conv_rgb_to_cmyk(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
+
+/* CMYK <-> YCbCr */
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_cmyk_4_to_ycbcr_n
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_SEC_COL_STEP 4
+#define IMAGE_WALK_DO_STEP do{ pixel_conv_cmyk_to_rgb(walk_pos, walk_sec_pos); pixel_conv_rgb_to_ycbcr(walk_pos, walk_pos); }while(0)
+#include <images/image-walk.h>
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_ycbcr_n_to_cmyk_4
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_COL_STEP 4
+#define IMAGE_WALK_DO_STEP do{ pixel_conv_ycbcr_to_rgb(walk_pos, walk_sec_pos); pixel_conv_rgb_to_cmyk(walk_pos, walk_pos); }while(0)
+#include <images/image-walk.h>
/* YCCK <-> RGB */
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_SEC_COL_STEP 4
#define IMAGE_WALK_DO_STEP do{ pixel_conv_ycck_to_rgb(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
static inline void
pixel_conv_rgb_to_ycck(byte *dest, byte *src)
#define IMAGE_WALK_DOUBLE
#define IMAGE_WALK_COL_STEP 4
#define IMAGE_WALK_DO_STEP do{ pixel_conv_rgb_to_ycck(walk_pos, walk_sec_pos); }while(0)
-#include "images/image-walk.h"
+#include <images/image-walk.h>
+
+/* YCCK <-> YCbCr */
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_ycck_4_to_ycbcr_n
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_SEC_COL_STEP 4
+#define IMAGE_WALK_DO_STEP do{ pixel_conv_ycck_to_rgb(walk_pos, walk_sec_pos); pixel_conv_rgb_to_ycbcr(walk_pos, walk_pos); }while(0)
+#include <images/image-walk.h>
+
+#define IMAGE_WALK_PREFIX(x) walk_##x
+#define IMAGE_WALK_FUNC_NAME image_conv_ycbcr_n_to_ycck_4
+#define IMAGE_WALK_DOUBLE
+#define IMAGE_WALK_COL_STEP 4
+#define IMAGE_WALK_DO_STEP do{ pixel_conv_ycbcr_to_rgb(walk_pos, walk_sec_pos); pixel_conv_rgb_to_ycck(walk_pos, walk_pos); }while(0)
+#include <images/image-walk.h>
/* Main functions */
return 1;
}
break;
+ case COLOR_SPACE_YCBCR:
+ if (dest->pixel_size == 1)
+ {
+ image_conv_ycbcr_n_to_gray_1(dest, src);
+ return 1;
+ }
+ break;
}
break;
case COLOR_SPACE_RGB:
case COLOR_SPACE_YCBCR:
switch (src->flags & IMAGE_CHANNELS_FORMAT)
{
+ case COLOR_SPACE_GRAYSCALE:
+ if (src->pixel_size == 1)
+ {
+ image_conv_gray_1_to_ycbcr_n(dest, src);
+ return 1;
+ }
+ break;
case COLOR_SPACE_RGB:
image_conv_rgb_n_to_ycbcr_n(dest, src);
return 1;
+ case COLOR_SPACE_CMYK:
+ if (src->pixel_size == 4)
+ {
+ image_conv_cmyk_4_to_ycbcr_n(dest, src);
+ return 1;
+ }
+ break;
+ case COLOR_SPACE_YCCK:
+ if (src->pixel_size == 4)
+ {
+ image_conv_ycck_4_to_ycbcr_n(dest, src);
+ return 1;
+ }
+ break;
}
break;
case COLOR_SPACE_CMYK:
switch (src->flags & IMAGE_CHANNELS_FORMAT)
{
- case COLOR_SPACE_RGB:
+ case COLOR_SPACE_RGB:
if (dest->pixel_size == 4)
{
image_conv_rgb_n_to_cmyk_4(dest, src);
return 1;
}
break;
+ case COLOR_SPACE_YCBCR:
+ if (dest->pixel_size == 4)
+ {
+ image_conv_ycbcr_n_to_cmyk_4(dest, src);
+ return 1;
+ }
+ break;
}
break;
case COLOR_SPACE_YCCK:
return 1;
}
break;
+ case COLOR_SPACE_YCBCR:
+ if (dest->pixel_size == 4)
+ {
+ image_conv_ycbcr_n_to_ycck_4(dest, src);
+ return 1;
+ }
+ break;
}
break;
}
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return;
case 2:
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; walk_pos[1] = walk_sec_pos[1]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
case 3:
# define IMAGE_WALK_PREFIX(x) walk_##x
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_UNROLL 2
# define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; walk_pos[1] = walk_sec_pos[1]; walk_pos[2] = walk_sec_pos[2]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
case 4:
# define IMAGE_WALK_PREFIX(x) walk_##x
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_UNROLL 2
# define IMAGE_WALK_DO_STEP do{ walk_pos[0] = walk_sec_pos[0]; walk_pos[1] = walk_sec_pos[1]; walk_pos[2] = walk_sec_pos[2]; walk_pos[3] = walk_sec_pos[3]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
default:
# define IMAGE_WALK_PREFIX(x) walk_##x
# define IMAGE_WALK_IMAGE dest
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_DO_STEP do{ for (uns i = 0; i < channels; i++) walk_pos[i] = walk_sec_pos[i]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
}
}
# define IMAGE_WALK_COL_STEP 2
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[1] = 255; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
}
break;
# define IMAGE_WALK_COL_STEP 4
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[3] = 255; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
return;
}
break;
# define IMAGE_WALK_IMAGE dest
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[dest->channels - 1] = 255; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
}
# define IMAGE_WALK_SEC_IMAGE src
# define IMAGE_WALK_UNROLL 4
# define IMAGE_WALK_DO_STEP do{ walk_pos[dest->channels - 1] = walk_sec_pos[src->channels - 1]; }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
}
# define IMAGE_WALK_UNROLL 2
# define IMAGE_WALK_DO_STEP do{ \
walk_pos[0] = image_conv_alpha_func(walk_pos[0], walk_sec_pos[src->channels - 1], a[0], b[0]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
case 3:
walk_pos[0] = image_conv_alpha_func(walk_pos[0], walk_sec_pos[src->channels - 1], a[0], b[0]); \
walk_pos[1] = image_conv_alpha_func(walk_pos[1], walk_sec_pos[src->channels - 1], a[1], b[1]); \
walk_pos[2] = image_conv_alpha_func(walk_pos[2], walk_sec_pos[src->channels - 1], a[2], b[2]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
}
# define IMAGE_WALK_DOUBLE
# define IMAGE_WALK_DO_STEP do{ for (uns i = 0; i < dest->channels; i++) \
walk_pos[i] = image_conv_alpha_func(walk_pos[i], walk_sec_pos[src->channels - 1], a[i], b[i]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
}
# define IMAGE_WALK_UNROLL 2
# define IMAGE_WALK_DO_STEP do{ \
walk_pos[0] = image_conv_alpha_func(walk_sec_pos[0], walk_sec_pos[src->channels - 1], a[0], b[0]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
case 3:
walk_pos[0] = image_conv_alpha_func(walk_sec_pos[0], walk_sec_pos[src->channels - 1], a[0], b[0]); \
walk_pos[1] = image_conv_alpha_func(walk_sec_pos[1], walk_sec_pos[src->channels - 1], a[1], b[1]); \
walk_pos[2] = image_conv_alpha_func(walk_sec_pos[2], walk_sec_pos[src->channels - 1], a[2], b[2]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
}
# define IMAGE_WALK_DOUBLE
# define IMAGE_WALK_DO_STEP do{ for (uns i = 0; i < dest->channels; i++) \
walk_pos[i] = image_conv_alpha_func(walk_sec_pos[i], walk_sec_pos[src->channels - 1], a[i], b[i]); }while(0)
-# include "images/image-walk.h"
+# include <images/image-walk.h>
}
return 1;
}