From 0efd007607fcce4490840be767f9b8b7dfa1efa4 Mon Sep 17 00:00:00 2001 From: kojima Date: Sun, 27 Feb 2000 19:51:30 +0000 Subject: [PATCH] added rotation --- wrlib/Makefile.am | 8 ++++- wrlib/Makefile.in | 25 +++++++++++---- wrlib/raster.c | 3 +- wrlib/testdraw.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++ wrlib/wraster.h | 5 ++- 5 files changed, 108 insertions(+), 10 deletions(-) diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am index 522d0e5e..88888e79 100644 --- a/wrlib/Makefile.am +++ b/wrlib/Makefile.am @@ -8,7 +8,7 @@ libwraster_la_LDFLAGS = -version-info 2:0:0 bin_SCRIPTS = get-wraster-flags -noinst_PROGRAMS = testgrad testdraw view +noinst_PROGRAMS = testgrad testdraw view testrot EXTRA_DIST = test.png tile.xpm ballot_box.xpm include_HEADERS = wraster.h @@ -32,6 +32,7 @@ libwraster_la_SOURCES = \ context.c \ misc.c \ scale.c \ + rotate.c \ convolve.c \ nxpm.c \ xpm.c \ @@ -66,6 +67,11 @@ testgrad_SOURCES = testgrad.c testgrad_LDADD = $(LIBLIST) +testrot_SOURCES = testrot.c + +testrot_LDADD = $(LIBLIST) + + testdraw_SOURCES = testdraw.c testdraw_LDADD = $(LIBLIST) diff --git a/wrlib/Makefile.in b/wrlib/Makefile.in index 2071b217..ec53e52b 100644 --- a/wrlib/Makefile.in +++ b/wrlib/Makefile.in @@ -70,6 +70,7 @@ GFXLIBS = @GFXLIBS@ HEADER_SEARCH_PATH = @HEADER_SEARCH_PATH@ ICONEXT = @ICONEXT@ INTLIBS = @INTLIBS@ +LD = @LD@ LIBPL = @LIBPL@ LIBRARY_SEARCH_PATH = @LIBRARY_SEARCH_PATH@ LIBTOOL = @LIBTOOL@ @@ -79,6 +80,7 @@ MAKEINFO = @MAKEINFO@ MOFILES = @MOFILES@ NETLIBS = @NETLIBS@ NLSDIR = @NLSDIR@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ @@ -101,12 +103,12 @@ libwraster_la_LDFLAGS = -version-info 2:0:0 bin_SCRIPTS = get-wraster-flags -noinst_PROGRAMS = testgrad testdraw view +noinst_PROGRAMS = testgrad testdraw view testrot EXTRA_DIST = test.png tile.xpm ballot_box.xpm include_HEADERS = wraster.h -libwraster_la_SOURCES = LookupCmap.c StdCmap.c StdCmap.h CrCmap.c DelCmap.c CmapAlloc.c raster.c draw.c color.c load.c save.c gradient.c xpixmap.c convert.c x86_specific.c context.c misc.c scale.c convolve.c nxpm.c xpm.c xutil.c ppm.c png.c jpeg.c tiff.c gif.c +libwraster_la_SOURCES = LookupCmap.c StdCmap.c StdCmap.h CrCmap.c DelCmap.c CmapAlloc.c raster.c draw.c color.c load.c save.c gradient.c xpixmap.c convert.c x86_specific.c context.c misc.c scale.c rotate.c convolve.c nxpm.c xpm.c xutil.c ppm.c png.c jpeg.c tiff.c gif.c INCLUDES = @DFLAGS@ @HEADER_SEARCH_PATH@ @@ -121,6 +123,10 @@ testgrad_SOURCES = testgrad.c testgrad_LDADD = $(LIBLIST) +testrot_SOURCES = testrot.c + +testrot_LDADD = $(LIBLIST) + testdraw_SOURCES = testdraw.c testdraw_LDADD = $(LIBLIST) @@ -143,8 +149,8 @@ libwraster_la_DEPENDENCIES = @ALLOCA@ libwraster_la_OBJECTS = LookupCmap.lo StdCmap.lo CrCmap.lo DelCmap.lo \ CmapAlloc.lo raster.lo draw.lo color.lo load.lo save.lo gradient.lo \ xpixmap.lo convert.lo x86_specific.lo context.lo misc.lo scale.lo \ -convolve.lo nxpm.lo xpm.lo xutil.lo ppm.lo png.lo jpeg.lo tiff.lo \ -gif.lo +rotate.lo convolve.lo nxpm.lo xpm.lo xutil.lo ppm.lo png.lo jpeg.lo \ +tiff.lo gif.lo PROGRAMS = $(noinst_PROGRAMS) testgrad_OBJECTS = testgrad.o @@ -156,6 +162,9 @@ testdraw_LDFLAGS = view_OBJECTS = view.o view_DEPENDENCIES = $(top_builddir)/wrlib/libwraster.la view_LDFLAGS = +testrot_OBJECTS = testrot.o +testrot_DEPENDENCIES = $(top_builddir)/wrlib/libwraster.la +testrot_LDFLAGS = SCRIPTS = $(bin_SCRIPTS) CFLAGS = @CFLAGS@ @@ -173,8 +182,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best -SOURCES = $(libwraster_la_SOURCES) $(testgrad_SOURCES) $(testdraw_SOURCES) $(view_SOURCES) -OBJECTS = $(libwraster_la_OBJECTS) $(testgrad_OBJECTS) $(testdraw_OBJECTS) $(view_OBJECTS) +SOURCES = $(libwraster_la_SOURCES) $(testgrad_SOURCES) $(testdraw_SOURCES) $(view_SOURCES) $(testrot_SOURCES) +OBJECTS = $(libwraster_la_OBJECTS) $(testgrad_OBJECTS) $(testdraw_OBJECTS) $(view_OBJECTS) $(testrot_OBJECTS) all: all-redirect .SUFFIXES: @@ -274,6 +283,10 @@ view: $(view_OBJECTS) $(view_DEPENDENCIES) @rm -f view $(LINK) $(view_LDFLAGS) $(view_OBJECTS) $(view_LDADD) $(LIBS) +testrot: $(testrot_OBJECTS) $(testrot_DEPENDENCIES) + @rm -f testrot + $(LINK) $(testrot_LDFLAGS) $(testrot_OBJECTS) $(testrot_LDADD) $(LIBS) + install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) diff --git a/wrlib/raster.c b/wrlib/raster.c index 87b761ef..b7742096 100644 --- a/wrlib/raster.c +++ b/wrlib/raster.c @@ -434,8 +434,7 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy, } } #undef OP -} - +} diff --git a/wrlib/testdraw.c b/wrlib/testdraw.c index b0fc2fe0..dc8970cf 100644 --- a/wrlib/testdraw.c +++ b/wrlib/testdraw.c @@ -282,6 +282,79 @@ testBevel() } +void testScale() +{ + RImage *image; + RImage *scaled; + XSetWindowAttributes val; + Pixmap pix; + Window win; + + val.background_pixel = ctx->black; + val.colormap = ctx->cmap; + win = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10, 140, 140, + 0, ctx->depth, InputOutput, ctx->visual, + CWColormap|CWBackPixel, &val); + XStoreName(dpy, win, "Scale"); + pix = XCreatePixmap(ctx->dpy, ctx->drawable, 140, 140, ctx->depth); + + image = RLoadImage(ctx, "ballot_box.xpm", 0); + if (!image) { + puts("couldnt load ballot_box.xpm"); + return; + } + + scaled = RScaleImage(image, 140, 140); + + RDestroyImage(image); + RConvertImage(ctx, scaled, &pix); + XSetWindowBackgroundPixmap(dpy, win, pix); + XMapRaised(dpy, win); + XClearWindow(dpy, win); + XFlush(dpy); +} + + +void testRotate() +{ + + RImage *image; + RImage *rotated; + XSetWindowAttributes val; + Pixmap pix; + Window win; + + image = RLoadImage(ctx, "ballot_box.xpm", 0); + if (!image) { + puts("couldnt load ballot_box.xpm"); + return; + } + + image = RScaleImage(image, 90, 180); + + + val.background_pixel = ctx->black; + val.colormap = ctx->cmap; + win = XCreateWindow(dpy, DefaultRootWindow(dpy), 10, 10, image->height, + image->width, + 0, ctx->depth, InputOutput, ctx->visual, + CWColormap|CWBackPixel, &val); + XStoreName(dpy, win, "Rotate"); + pix = XCreatePixmap(ctx->dpy, ctx->drawable, image->height, image->width, + ctx->depth); + + rotated = RRotateImage(image, 90.0); + + RDestroyImage(image); + RConvertImage(ctx, rotated, &pix); + XSetWindowBackgroundPixmap(dpy, win, pix); + XMapRaised(dpy, win); + XClearWindow(dpy, win); + XFlush(dpy); +} + + + void drawClip() { @@ -548,6 +621,10 @@ int main(int argc, char **argv) testBevel(); drawClip(); + + testScale(); + + testRotate(); /* benchmark();*/ diff --git a/wrlib/wraster.h b/wrlib/wraster.h index 302b49a8..4fcb101a 100644 --- a/wrlib/wraster.h +++ b/wrlib/wraster.h @@ -1,7 +1,7 @@ /* * Raster graphics library * - * Copyright (c) 1997, 1998, 1999 Alfredo K. Kojima + * Copyright (c) 1997 ~ 2000 Alfredo K. Kojima * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -355,7 +355,10 @@ RImage *RScaleImage(RImage *image, unsigned new_width, unsigned new_height); RImage *RSmoothScaleImage(RImage *src, unsigned new_width, unsigned new_height); + +RImage *RRotateImage(RImage *image, float angle); + RImage *RMakeTiledImage(RImage *tile, unsigned width, unsigned height); RImage* RMakeCenteredImage(RImage *image, unsigned width, unsigned height,