Home  |  Linux  | Mysql  | PHP  | XML
Date:Mon Sep 13 16:09:07 2010
Subject:svn:_/gd/trunk/libgd/src/_CMakeLists.txt_Makefile.am_gd.h_gd_filter.c_gd_pixelate.c
kalle Mon, 13 Sep 2010 16:09:07 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=303327

Log:
Merge gd_pixelate.c into gd_filter.c so we have one file with all the filters

Changed paths:
U gd/trunk/libgd/src/CMakeLists.txt
U gd/trunk/libgd/src/Makefile.am
U gd/trunk/libgd/src/gd.h
U gd/trunk/libgd/src/gd_filter.c
D gd/trunk/libgd/src/gd_pixelate.c

Modified: gd/trunk/libgd/src/CMakeLists.txt
===================================================================
--- gd/trunk/libgd/src/CMakeLists.txt 2010-09-13 15:44:53 UTC (rev 303326)
+++ gd/trunk/libgd/src/CMakeLists.txt 2010-09-13 16:09:07 UTC (rev 303327)
@@ -29,7 +29,6 @@
gd_jpeg.c
gd_nnquant.c
gd_nnquant.h
- gd_pixelate.c
gd_png.c
gd_tiff.c
gd_tga.c

Modified: gd/trunk/libgd/src/Makefile.am
===================================================================
--- gd/trunk/libgd/src/Makefile.am 2010-09-13 15:44:53 UTC (rev 303326)
+++ gd/trunk/libgd/src/Makefile.am 2010-09-13 16:09:07 UTC (rev 303327)
@@ -13,7 +13,7 @@

lib_LTLIBRARIES = libgd.la

-libgd_la_SOURCES = gd.c gd_color.c gd_color_map.c gd_transform.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h gd_pixelate.c gd_filter.c
+libgd_la_SOURCES = gd.c gd_color.c gd_color_map.c gd_transform.c gdfx.c gd_security.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_gif_in.c gd_gif_out.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h wbmp.c wbmp.h gd_filter.c

libgd_la_LDFLAGS = -version-info 2:0:0 $(XTRA_LDFLAGS)


Modified: gd/trunk/libgd/src/gd.h
===================================================================
--- gd/trunk/libgd/src/gd.h 2010-09-13 15:44:53 UTC (rev 303326)
+++ gd/trunk/libgd/src/gd.h 2010-09-13 16:09:07 UTC (rev 303327)
@@ -777,6 +777,7 @@

BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor);

+/* Filters - defined in gd_filter.c */
enum gdPixelateMode {
GD_PIXELATE_UPPERLEFT,
GD_PIXELATE_AVERAGE

Modified: gd/trunk/libgd/src/gd_filter.c
===================================================================
--- gd/trunk/libgd/src/gd_filter.c 2010-09-13 15:44:53 UTC (rev 303326)
+++ gd/trunk/libgd/src/gd_filter.c 2010-09-13 16:09:07 UTC (rev 303327)
@@ -9,7 +9,6 @@
#include <time.h>

#define PIXEL_FUNCTION_DECLARE(f) int (*f)(gdImagePtr, int, int)
-
#define GET_PIXEL_FUNCTION(src)(src->trueColor ? gdImageGetTrueColorPixel : gdImageGetPixel)

#ifdef WIN32
@@ -97,3 +96,58 @@

return 1;
}
+int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode)
+{
+ int x, y;
+
+ if (block_size <= 0) {
+ return 0;
+ } else if (block_size == 1) {
+ return 1;
+ }
+ switch (mode) {
+ case GD_PIXELATE_UPPERLEFT:
+ for (y = 0; y < im->sy; y += block_size) {
+ for (x = 0; x < im->sx; x += block_size) {
+ if (gdImageBoundsSafe(im, x, y)) {
+ int c = gdImageGetPixel(im, x, y);
+ gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
+ }
+ }
+ }
+ break;
+ case GD_PIXELATE_AVERAGE:
+ for (y = 0; y < im->sy; y += block_size) {
+ for (x = 0; x < im->sx; x += block_size) {
+ int a, r, g, b, c;
+ int total;
+ int cx, cy;
+
+ a = r = g = b = c = total = 0;
+ /* sampling */
+ for (cy = 0; cy < block_size; cy++) {
+ for (cx = 0; cx < block_size; cx++) {
+ if (!gdImageBoundsSafe(im, x + cx, y + cy)) {
+ continue;
+ }
+ c = gdImageGetPixel(im, x + cx, y + cy);
+ a += gdImageAlpha(im, c);
+ r += gdImageRed(im, c);
+ g += gdImageGreen(im, c);
+ b += gdImageBlue(im, c);
+ total++;
+ }
+ }
+ /* drawing */
+ if (total > 0) {
+ c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total);
+ gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
+ }
+ }
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}

Deleted: gd/trunk/libgd/src/gd_pixelate.c
===================================================================
--- gd/trunk/libgd/src/gd_pixelate.c 2010-09-13 15:44:53 UTC (rev 303326)
+++ gd/trunk/libgd/src/gd_pixelate.c 2010-09-13 16:09:07 UTC (rev 303327)
@@ -1,57 +0,0 @@
-#include "gd.h"
-
-int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode)
-{
- int x, y;
-
- if (block_size <= 0) {
- return 0;
- } else if (block_size == 1) {
- return 1;
- }
- switch (mode) {
- case GD_PIXELATE_UPPERLEFT:
- for (y = 0; y < im->sy; y += block_size) {
- for (x = 0; x < im->sx; x += block_size) {
- if (gdImageBoundsSafe(im, x, y)) {
- int c = gdImageGetPixel(im, x, y);
- gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
- }
- }
- }
- break;
- case GD_PIXELATE_AVERAGE:
- for (y = 0; y < im->sy; y += block_size) {
- for (x = 0; x < im->sx; x += block_size) {
- int a, r, g, b, c;
- int total;
- int cx, cy;
-
- a = r = g = b = c = total = 0;
- /* sampling */
- for (cy = 0; cy < block_size; cy++) {
- for (cx = 0; cx < block_size; cx++) {
- if (!gdImageBoundsSafe(im, x + cx, y + cy)) {
- continue;
- }
- c = gdImageGetPixel(im, x + cx, y + cy);
- a += gdImageAlpha(im, c);
- r += gdImageRed(im, c);
- g += gdImageGreen(im, c);
- b += gdImageBlue(im, c);
- total++;
- }
- }
- /* drawing */
- if (total > 0) {
- c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total);
- gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
- }
- }
- }
- break;
- default:
- return 0;
- }
- return 1;
-}

Navigate in group php.gd.cvs at sever news.php.net
Previous Next





  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants