Browse Source

image: remove dead or useless or low quality code.

undefined
Sam Hocevar 10 years ago
parent
commit
5f02903598
4 changed files with 0 additions and 301 deletions
  1. +0
    -3
      TODO
  2. +0
    -124
      src/image/codec.cpp
  3. +0
    -127
      src/image/colorstring.cpp
  4. +0
    -47
      src/image/paint/rectangle.cpp

+ 0
- 3
TODO View File

@@ -22,9 +22,7 @@ Image:
· analysis/measure.cpp
· codec/coreimage.cpp
· codec/coreimage.h
· codec.cpp
· codec/jpeg.cpp
· colorstring.cpp
· combine/blit.cpp
· combine/merge.cpp
· combine/minmax.cpp
@@ -39,7 +37,6 @@ Image:
· paint/bezier.cpp
· paint/floodfill.cpp
· paint/line.cpp
· paint/rectangle.cpp
· quantize/reduce.cpp
· sequence.cpp


+ 0
- 124
src/image/codec.cpp View File

@@ -1,124 +0,0 @@
/*
* libpipi Pathetic image processing interface library
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* codec.c: image I/O functions
*/

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "pipi.h"
#include "pipi-internals.h"

pipi_image_t *pipi_load(char const *name)
{
pipi_image_t *ret = NULL;

if(!strncmp(name, "random:", 7) ||
!strncmp(name, "ediff:", 6) ||
!strncmp(name, "halftone:", 6) ||
!strncmp(name, "bayer:", 6))
ret = pipi_load_stock(name);

if(!ret)
ret = pipi_load_oric(name);

#if USE_JPEG
if(!ret)
ret = pipi_load_jpeg(name);
#endif
#if USE_IMLIB2
if(!ret)
ret = pipi_load_imlib2(name);
#endif
#if USE_OPENCV
if(!ret)
ret = pipi_load_opencv(name);
#endif
#if USE_SDL
if(!ret)
ret = pipi_load_sdl(name);
#endif
#if USE_GDIPLUS
if(!ret)
ret = pipi_load_gdiplus(name);
#endif
#if USE_GDI
if(!ret)
ret = pipi_load_gdi(name);
#endif
#if USE_COCOA
if(!ret)
ret = pipi_load_coreimage(name);
#endif
return ret;
}

void pipi_free(pipi_image_t *img)
{
int i;

for(i = 0; i < PIPI_PIXELS_MAX; i++)
if(i != img->codec_format && img->p[i].pixels)
free(img->p[i].pixels);

if(img->codec_priv)
img->codec_free(img);

free(img);
}

int pipi_save(pipi_image_t *img, const char *name)
{
int ret = -1;

if(ret < 0)
ret = pipi_save_oric(img, name);

#if USE_JPEG
if(ret < 0)
ret = pipi_save_jpeg(img, name);
#endif
#if USE_IMLIB2
if(ret < 0)
ret = pipi_save_imlib2(img, name);
#endif
#if USE_OPENCV
if(ret < 0)
ret = pipi_save_opencv(img, name);
#endif
#if USE_SDL
if(ret < 0)
ret = pipi_save_sdl(img, name);
#endif
#if USE_GDIPLUS
if(ret < 0)
ret = pipi_save_gdiplus(img, name);
#endif
#if USE_GDI
if(ret < 0)
ret = pipi_save_gdi(img, name);
#endif
#if USE_COCOA
if(ret < 0)
ret = pipi_save_coreimage(img, name);
#endif

return ret;
}


+ 0
- 127
src/image/colorstring.cpp View File

@@ -1,127 +0,0 @@
/*
* libpipi Pathetic image processing interface library
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
* 2008 Jean-Yves Lamoureux <jylam@lnxscene.org
* All Rights Reserved
*
* $Id$
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* colorstring.c: color from string functions
*/

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#include "pipi.h"
#include "pipi-internals.h"


struct color_table
{
char name[255];
float a,r,g,b;
};

struct color_table color_table[] =
{
{ "black" , 1, 0, 0, 0 },
{ "white" , 1, 1, 1, 1 },
{ "red" , 1, 1, 0, 0 },
{ "green" , 1, 0, 1, 0 },
{ "blue" , 1, 0, 0, 1 },
{ "yellow" , 1, 1, 1, 0 },
{ "cyan" , 1, 0, 1, 1 },
{ "magenta", 1, 1, 0, 1 },
{ "grey" , 1, 0.5, 0.5, 0.5 },
{ "gray" , 1, 0.5, 0.5, 0.5 },
{ "grey50" , 1, 0.5, 0.5, 0.5 },
{ "gray50" , 1, 0.5, 0.5, 0.5 },
{ "grey25" , 1, 0.25, 0.25, 0.25 },
{ "gray25" , 1, 0.25, 0.25, 0.25 },
};



pipi_pixel_t *pipi_get_color_from_string(const char* s)
{
pipi_pixel_t *color;

if(!s) return NULL;

color = malloc(sizeof(pipi_pixel_t));

if(s[0] == '#')
{
uint32_t c = 0;
sscanf(s, "%x", &c);

color->pixel_float.a = ((c&0xFF000000)>>24) / 255.0f;
color->pixel_float.r = ((c&0x00FF0000)>>16) / 255.0f;
color->pixel_float.g = ((c&0x0000FF00)>>8) / 255.0f;
color->pixel_float.b = ((c&0x000000FF)>>0) / 255.0f;
}
else if(!strncmp(s, "rgb(", 4))
{
uint32_t r ,g ,b;
sscanf(s, "rgb(%u,%u,%u)", &r, &g, &b);
color->pixel_float.r = r / 255.0f;
color->pixel_float.g = g / 255.0f;
color->pixel_float.b = b / 255.0f;
}
else if(!strncmp(s, "frgb(", 5))
{
float r ,g ,b;
sscanf(s, "frgb(%f,%f,%f)", &r, &g, &b);
color->pixel_float.r = r;
color->pixel_float.g = g;
color->pixel_float.b = b;
}
else if(!strncmp(s, "argb(", 4))
{
uint32_t a, r ,g ,b;
sscanf(s, "argb(%u,%u,%u,%u)", &a, &r, &g, &b);
color->pixel_float.a = a / 255.0f;
color->pixel_float.r = r / 255.0f;
color->pixel_float.g = g / 255.0f;
color->pixel_float.b = b / 255.0f;
}
else if(!strncmp(s, "fargb(", 5))
{
float a, r ,g ,b;
sscanf(s, "fargb(%f, %f,%f,%f)", &a, &r, &g, &b);
color->pixel_float.a = a;
color->pixel_float.r = r;
color->pixel_float.g = g;
color->pixel_float.b = b;
}
else
{
unsigned int i;
for(i=0; i<sizeof(color_table); i++)
{
if(!strcasecmp(color_table[i].name,s))
{
color->pixel_float.a = color_table[i].a;
color->pixel_float.r = color_table[i].r;
color->pixel_float.g = color_table[i].g;
color->pixel_float.b = color_table[i].b;
break;
}
}


}
return color;
}

+ 0
- 47
src/image/paint/rectangle.cpp View File

@@ -1,47 +0,0 @@
/*
* libpipi Pathetic image processing interface library
* Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
* 2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
* All Rights Reserved
*
* $Id$
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

/*
* rectangle.c: rectangle rendering functions
*/

/* XXX: this file is a JOKE, don't use it */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "pipi.h"
#include "pipi-internals.h"

int pipi_draw_rectangle(pipi_image_t *img , int xa, int ya, int xb, int yb, uint32_t c, int aa)
{
while(ya < yb)
{
pipi_draw_line(img, xa, ya, xb, ya, c, aa);
ya++;
}

while(ya > yb)
{
pipi_draw_line(img, xa, ya, xb, ya, c, aa);
ya--;
}

return pipi_draw_line(img, xa, yb, xb, yb, c, aa);
}


Loading…
Cancel
Save