]> git.imager.perl.org - imager.git/blobdiff - immacros.h
Coverity complained colors could be left uninitialized.
[imager.git] / immacros.h
index 6d7cc75bea30d307feb1031d0f7be3fb1be565b2..8b45f58781ee50e888dfa10ea5b498766999791b 100644 (file)
@@ -16,19 +16,7 @@ Return true if the image has an alpha channel.
 =cut
 */
 
-#define i_img_has_alpha(im) ((im)->channels == 2 || (im)->channels == 4)
-
-/*
-=item i_img_color_channels(C<im>)
-
-=category Image Information
-
-The number of channels holding color information.
-
-=cut
-*/
-
-#define i_img_color_channels(im) (i_img_has_alpha(im) ? (im)->channels - 1 : (im)->channels)
+#define i_img_has_alpha(im) (i_img_alpha_channel((im), NULL))
 
 /*
 =item i_psamp(im, left, right, y, samples, channels, channel_count)
@@ -128,17 +116,18 @@ returns -1 and pushes an error.
 #define i_img_type(im) ((im)->type)
 #define i_img_bits(im) ((im)->bits)
 
+#define pIMCTX im_context_t my_im_ctx
+
 #ifdef IMAGER_NO_CONTEXT
-#define dIMCTX im_context_t my_im_ctx = im_get_context()
-#define dIMCTXa(a) im_context_t my_im_ctx = im_get_context()
-#define dIMCTXim(im) im_context_t my_im_ctx = (im)->context
+#define dIMCTXctx(ctx) pIMCTX = (ctx)
+#define dIMCTX dIMCTXctx(im_get_context())
+#define dIMCTXim(im) dIMCTXctx((im)->context)
+#define dIMCTXio(io) dIMCTXctx((io)->context)
 #define aIMCTX my_im_ctx
 #else
 #define aIMCTX im_get_context()
 #endif
 
-#define pIMCTX im_context_t my_im_ctx
-
 #define i_img_8_new(xsize, ysize, channels) im_img_8_new(aIMCTX, (xsize), (ysize), (channels))
 #define i_img_16_new(xsize, ysize, channels) im_img_16_new(aIMCTX, (xsize), (ysize), (channels))
 #define i_img_double_new(xsize, ysize, channels) im_img_double_new(aIMCTX, (xsize), (ysize), (channels))
@@ -154,5 +143,12 @@ returns -1 and pushes an error.
 #define i_clear_error() im_clear_error(aIMCTX)
 #define i_push_errorvf(code, fmt, args) im_push_errorvf(aIMCTX, code, fmt, args)
 #define i_push_error(code, msg) im_push_error(aIMCTX, code, msg)
+#define i_errors() im_errors(aIMCTX)
+
+#define io_new_fd(fd) im_io_new_fd(aIMCTX, (fd))
+#define io_new_bufchain() im_io_new_bufchain(aIMCTX)
+#define io_new_buffer(data, len, closecb, closectx) im_io_new_buffer(aIMCTX, (data), (len), (closecb), (closectx))
+#define io_new_cb(p, readcb, writecb, seekcb, closecb, destroycb) \
+  im_io_new_cb(aIMCTX, (p), (readcb), (writecb), (seekcb), (closecb), (destroycb))
 
 #endif