]> git.imager.perl.org - imager.git/blobdiff - hlines.c
correct an old bug link
[imager.git] / hlines.c
index aa5c15b23ee90544e1e4f44b31508ad728d7297d..3dbbd77f3e10b79522557666be7c3c8f99fc3445 100644 (file)
--- a/hlines.c
+++ b/hlines.c
@@ -1,4 +1,5 @@
-#include "imagei.h"
+#define IMAGER_NO_CONTEXT
+#include "imageri.h"
 #include <stdlib.h>
 
 #define OVERLAPPED(start1, end1, start2, end2) \
@@ -59,16 +60,17 @@ range.  Any x or y values outside the given ranges will be ignored.
 void
 i_int_init_hlines(
                  i_int_hlines *hlines, 
-                 int start_y, 
-                 int count_y,
-                 int start_x, 
-                 int width_x
+                 i_img_dim start_y, 
+                 i_img_dim count_y,
+                 i_img_dim start_x, 
+                 i_img_dim width_x
                  )
 {
-  int bytes = count_y * sizeof(i_int_hline_entry *);
+  size_t bytes = count_y * sizeof(i_int_hline_entry *);
 
   if (bytes / count_y != sizeof(i_int_hline_entry *)) {
-    m_fatal(3, "integer overflow calculating memory allocation\n");
+    dIMCTX;
+    im_fatal(aIMCTX, 3, "integer overflow calculating memory allocation\n");
   }
 
   hlines->start_y = start_y;
@@ -107,11 +109,12 @@ Add to the list, merging with existing entries.
 */
 
 void
-i_int_hlines_add(i_int_hlines *hlines, int y, int x, int width) {
-  int x_limit = x + width;
+i_int_hlines_add(i_int_hlines *hlines, i_img_dim y, i_img_dim x, i_img_dim width) {
+  i_img_dim x_limit = x + width;
 
   if (width < 0) {
-    m_fatal(3, "negative width %d passed to i_int_hlines_add\n", width);
+    dIMCTX;
+    im_fatal(aIMCTX, 3, "negative width %d passed to i_int_hlines_add\n", width);
   }
 
   /* just return if out of range */
@@ -132,7 +135,7 @@ i_int_hlines_add(i_int_hlines *hlines, int y, int x, int width) {
 
   if (hlines->entries[y - hlines->start_y]) {
     i_int_hline_entry *entry = hlines->entries[y - hlines->start_y];
-    int i, found = -1;
+    i_img_dim i, found = -1;
     
     for (i = 0; i < entry->count; ++i) {
       i_int_hline_seg *seg = entry->segs + i;
@@ -183,7 +186,7 @@ i_int_hlines_add(i_int_hlines *hlines, int y, int x, int width) {
       /* add a new segment */
       if (entry->count == entry->alloc) {
        /* expand it */
-       int alloc = entry->alloc * 3 / 2;
+       size_t alloc = entry->alloc * 3 / 2;
        entry = myrealloc(entry, sizeof(i_int_hline_entry) +
                           sizeof(i_int_hline_seg) * (alloc - 1));
        entry->alloc = alloc;
@@ -218,8 +221,8 @@ Releases all memory associated with the structure.
 
 void
 i_int_hlines_destroy(i_int_hlines *hlines) {
-  int entry_count = hlines->limit_y - hlines->start_y;
-  int i;
+  size_t entry_count = hlines->limit_y - hlines->start_y;
+  size_t i;
   
   for (i = 0; i < entry_count; ++i) {
     if (hlines->entries[i])
@@ -239,8 +242,8 @@ Fill the areas given by hlines with color.
 */
 
 void
-i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, i_color *col) {
-  int y, i, x;
+i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, const i_color *col) {
+  i_img_dim y, i, x;
 
   for (y = hlines->start_y; y < hlines->limit_y; ++y) {
     i_int_hline_entry *entry = hlines->entries[y - hlines->start_y];
@@ -260,11 +263,30 @@ i_int_hlines_fill_color(i_img *im, i_int_hlines *hlines, i_color *col) {
 
 i_int_hlines_fill_fill(im, hlines, fill)
 
+=cut
 */
 void
 i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill) {
-  int y, i, x;
+  i_render r;
+  i_img_dim y, i;
+
+  i_render_init(&r, im, im->xsize);
 
+  for (y = hlines->start_y; y < hlines->limit_y; ++y) {
+    i_int_hline_entry *entry = hlines->entries[y - hlines->start_y];
+    if (entry) {
+      for (i = 0; i < entry->count; ++i) {
+       i_int_hline_seg *seg = entry->segs + i;
+       i_img_dim width = seg->x_limit-seg->minx;
+       
+       i_render_fill(&r, seg->minx, y, width, NULL, fill);
+      }
+    }
+  }
+  i_render_done(&r);
+  
+#if 1
+#else
   if (im->bits == i_8_bits && fill->fill_with_color) {
     i_color *line = mymalloc(sizeof(i_color) * im->xsize);
     i_color *work = NULL;
@@ -275,7 +297,7 @@ i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill) {
       if (entry) {
        for (i = 0; i < entry->count; ++i) {
          i_int_hline_seg *seg = entry->segs + i;
-         int width = seg->x_limit-seg->minx;
+         i_img_dim width = seg->x_limit-seg->minx;
 
          if (fill->combine) {
            i_glin(im, seg->minx, seg->x_limit, y, line);
@@ -306,7 +328,7 @@ i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill) {
       if (entry) {
        for (i = 0; i < entry->count; ++i) {
          i_int_hline_seg *seg = entry->segs + i;
-         int width = seg->x_limit-seg->minx;
+         i_img_dim width = seg->x_limit-seg->minx;
 
          if (fill->combinef) {
            i_glinf(im, seg->minx, seg->x_limit, y, line);
@@ -327,6 +349,7 @@ i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill) {
     if (work)
       myfree(work);
   }
+#endif
 }
 
 /*
@@ -334,7 +357,7 @@ i_int_hlines_fill_fill(i_img *im, i_int_hlines *hlines, i_fill_t *fill) {
 
 =head1 AUTHOR
 
-Tony Cook <tony@imager.perl.org>
+Tony Cook <tonyc@cpan.org>
 
 =head1 REVISION