mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
added rotation
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -438,7 +438,6 @@ RCombineAreaWithOpaqueness(RImage *image, RImage *src, int sx, int sy,
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
RCombineImageWithColor(RImage *image, RColor *color)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
@@ -549,6 +622,10 @@ int main(int argc, char **argv)
|
||||
|
||||
drawClip();
|
||||
|
||||
testScale();
|
||||
|
||||
testRotate();
|
||||
|
||||
/* benchmark();*/
|
||||
|
||||
getchar();
|
||||
|
||||
@@ -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
|
||||
@@ -356,6 +356,9 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user