Quellcode durchsuchen

* Start shipping unit tests. The first one checks that converting an

8-bit per channel picture to float32 then back again does not change
    the image.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2621 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam vor 16 Jahren
Ursprung
Commit
3d86c2f45a
6 geänderte Dateien mit 79 neuen und 1 gelöschten Zeilen
  1. +1
    -0
      .gitignore
  2. +1
    -1
      Makefile.am
  3. +1
    -0
      configure.ac
  4. +11
    -0
      test/Makefile.am
  5. BIN
      test/mona.png
  6. +65
    -0
      test/u8tof32tou8.c

+ 1
- 0
.gitignore Datei anzeigen

@@ -12,6 +12,7 @@ pipi/pipi.pc
genethumb/genethumb
examples/blur
examples/img2rubik
test/u8tof32tou8
stamp-h1
.auto
.deps


+ 1
- 1
Makefile.am Datei anzeigen

@@ -1,6 +1,6 @@
# $Id$

SUBDIRS = pipi genethumb examples
SUBDIRS = pipi genethumb examples test

EXTRA_DIST = bootstrap common.h
AUTOMAKE_OPTIONS = dist-bzip2


+ 1
- 0
configure.ac Datei anzeigen

@@ -109,6 +109,7 @@ AC_CONFIG_FILES([
pipi/Makefile
genethumb/Makefile
examples/Makefile
test/Makefile
])
AC_CONFIG_FILES([
pipi/pipi.pc


+ 11
- 0
test/Makefile.am Datei anzeigen

@@ -0,0 +1,11 @@

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

noinst_PROGRAMS = u8tof32tou8

TESTS = $(noinst_PROGRAMS)

u8tof32tou8_LDADD = ../pipi/libpipi.la

EXTRA_DIST = mona.png


BIN
test/mona.png Datei anzeigen

Vorher Nachher
Breite: 512  |  Höhe: 512  |  Größe: 624 KiB

+ 65
- 0
test/u8tof32tou8.c Datei anzeigen

@@ -0,0 +1,65 @@
/*
* libpipi Proper image processing implementation 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.
*/

/*
* loadsave.c: unit test to check that converting an image to float values
* and back to 8-bit integers does not change it.
*/

#include "config.h"
#include "common.h"

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

#include <pipi.h>

int main(int argc, char *argv[])
{
pipi_image_t *img1, *img2;
pipi_pixels_t *pix1, *pix2;
uint32_t *data1, *data2;
int x, y, ret = EXIT_SUCCESS;

img1 = pipi_load("mona.png");
img2 = pipi_load("mona.png");

pix1 = pipi_getpixels(img1, PIPI_PIXELS_RGBA32);
data1 = (uint32_t *)pix1->pixels;

pipi_getpixels(img2, PIPI_PIXELS_RGBA_F);
pix2 = pipi_getpixels(img2, PIPI_PIXELS_RGBA32);
data2 = (uint32_t *)pix2->pixels;

for(y = 0; y < pix1->h; y++)
{
for(x = 0; x < pix1->w; x++)
{
uint32_t a = data1[y * pix1->w + x];
uint32_t b = data2[y * pix2->w + x];

if(a != b)
{
printf("loadsave: %08x != %08x at (%i,%i)\n", a, b, x, y);
ret = EXIT_FAILURE;
}
}
}

pipi_free(img1);
pipi_free(img2);

return ret;
}


Laden…
Abbrechen
Speichern