Преглед на файлове

* Added a bezier curve primitive (2 control points).

* Fixed a float overflow in antialiased lines (this algorithm is a mess, and I need to rewrite it)
 * Wrote a bunch of craderies degueulasses to avoid having y1 already defined in math.h
 * Did I say this antialiased line implementation sucks ?


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2788 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
jylam преди 16 години
родител
ревизия
306ec17156
променени са 6 файла, в които са добавени 27 реда и са изтрити 12 реда
  1. +4
    -1
      examples/Makefile.am
  2. +1
    -1
      examples/line.c
  3. +1
    -0
      pipi/Makefile.am
  4. +1
    -1
      pipi/paint/aline_template.h
  5. +19
    -9
      pipi/paint/line.c
  6. +1
    -0
      pipi/pipi.h

+ 4
- 1
examples/Makefile.am Целия файл

@@ -2,7 +2,7 @@

AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/pipi

bin_PROGRAMS = edd img2rubik sharpen floodfill line
bin_PROGRAMS = edd img2rubik sharpen floodfill line bezier

edd_SOURCES = edd.c
edd_LDADD = ../pipi/libpipi.la
@@ -18,3 +18,6 @@ floodfill_LDADD = ../pipi/libpipi.la

line_SOURCES = line.c
line_LDADD = ../pipi/libpipi.la

bezier_SOURCES = bezier.c
bezier_LDADD = ../pipi/libpipi.la

+ 1
- 1
examples/line.c Целия файл

@@ -37,7 +37,7 @@ int main(int argc, char *argv[])

while(count--) {
pipi_draw_line(newimg,
rand() % w, rand() % h,
rand() , rand() % h,
rand() % w, rand() % h,
rand(),
1);


+ 1
- 0
pipi/Makefile.am Целия файл

@@ -44,6 +44,7 @@ codec_sources =
paint_sources = \
paint/floodfill.c \
paint/line.c paint/line_template.h paint/aline_template.h \
paint/bezier.c \
paint/tile.c

render_sources = \


+ 1
- 1
pipi/paint/aline_template.h Целия файл

@@ -70,7 +70,7 @@ if (fabsf(xd) > fabsf(yd)) {
val2 += 0.3*focus;

PLOT(x, yf, val1);
PLOT(x, yf+1, val2);
PLOT(x, (yf+1)<y1?(yf+1):yf, val2);

yf = yf + g;
}


+ 19
- 9
pipi/paint/line.c Целия файл

@@ -24,6 +24,11 @@
#include <stdlib.h>
#include <string.h>

#undef __USE_MISC /* THAT sucks */
#undef __USE_XOPEN /* THAT sucks, too (avoid declaring y1 in math.h) */
#include <math.h>


#include "pipi.h"
#include "pipi_internals.h"

@@ -268,10 +273,11 @@ static void draw_aliased_line_gray(pipi_image_t *img, struct line* s)

/* Xiaolin Wu's line algorithm, as seen at http://portal.acm.org/citation.cfm?id=122734 */

/* math.h doesn't like y0 (sucker) */
/* math.h doesn't like y1 (sucker) */
float floorf(float x);
float truncf(float x);
float fabsf(float x);

static float fractf(float d) { return (d - floorf(d)); }
static float fractinvf(float d) { return (1 - (d - floorf(d))); }

@@ -286,13 +292,13 @@ static void draw_antialiased_line_float(pipi_image_t *img, struct line* s)
s->buf_f[qwer] = (c*s->colorf[0]) + (1-c) * s->buf_f[qwer]; \
s->buf_f[qweg] = (c*s->colorf[1]) + (1-c) * s->buf_f[qweg]; \
s->buf_f[qweb] = (c*s->colorf[2]) + (1-c) * s->buf_f[qweb]; \
if(s->buf_f[qwer] > 0.8f) s->buf_f[qwer] = 0.8f; /* DEBUG LOL !*/ \
if(s->buf_f[qwer] < 0.2f) s->buf_f[qwer] = 0.2f; \
if(s->buf_f[qweg] > 0.8f) s->buf_f[qweg] = 0.8f; \
if(s->buf_f[qweg] < 0.2f) s->buf_f[qweg] = 0.2f; \
if(s->buf_f[qweb] > 0.8f) s->buf_f[qweb] = 0.8f; \
if(s->buf_f[qweb] < 0.2f) s->buf_f[qweb] = 0.2f; \
}
if(s->buf_f[qwer] > 1.0f) s->buf_f[qwer] = 1.0f; \
if(s->buf_f[qwer] < 0.0f || isnan(s->buf_f[qwer])) s->buf_f[qwer] = 0.0f; \
if(s->buf_f[qweg] > 1.0f) s->buf_f[qweg] = 1.0f; \
if(s->buf_f[qweg] < 0.0f || isnan(s->buf_f[qweg])) s->buf_f[qweg] = 0.0f; \
if(s->buf_f[qweb] > 1.0f) s->buf_f[qweb] = 1.0f; \
if(s->buf_f[qweb] < 0.0f || isnan(s->buf_f[qweb])) s->buf_f[qweb] = 0.0f; }
#include "aline_template.h"
}

@@ -301,6 +307,10 @@ static void draw_antialiased_line_gray(pipi_image_t *img, struct line* s)
{
#undef PLOT
#define PLOT(x, y, c) s->buf_f[((int)(x))+((int)(y))*img->w] = \
(c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w];
(c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w]; \
if(s->buf_f[((int)(x))+((int)(y))*img->w] > 1.0f) s->buf_f[((int)(x))+((int)(y))*img->w] = 1.0f; \
if(s->buf_f[((int)(x))+((int)(y))*img->w] < 0.0f) s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \
if(isnan(s->buf_f[((int)(x))+((int)(y))*img->w])) s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f;

#include "aline_template.h"
}

+ 1
- 0
pipi/pipi.h Целия файл

@@ -156,6 +156,7 @@ extern int pipi_flood_fill(pipi_image_t *,
extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
int , uint32_t, int);
extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int);
extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);

extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *,


Зареждане…
Отказ
Запис