-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zvezdochiot
committed
Feb 21, 2018
0 parents
commit 7ebfe35
Showing
8 changed files
with
2,730 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Simplified BSD License | ||
http://www.opensource.org/licenses/bsd-license.html | ||
|
||
Copyright (c) 2010-2011, Pascal Getreuer | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in | ||
the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# GCC makefile for Ipol.im library image input-output | ||
# Pascal Getreuer | ||
# May 4, 2012 | ||
|
||
LIBIPOLN=libipoliio.so | ||
LIBIPOLV=0 | ||
LIBIPOLD=20130706 | ||
## | ||
# The following three statements determine the build configuration. | ||
# For handling different image formats, the program can be linked with | ||
# the libjpeg, libpng, and libtiff libraries. For each library, set | ||
# the flags needed for linking. To disable use of a library, comment | ||
# its statement. You can disable all three (BMP is always supported). | ||
LDLIBJPEG=-ljpeg | ||
LDLIBPNG=-lpng | ||
LDLIBTIFF=-ltiff | ||
|
||
## | ||
# Standard make settings | ||
SHELL=/bin/sh | ||
CFLAGS=-O3 -ansi -pedantic -Wall -Wextra | ||
LDFLAGS= | ||
LDLIBS=-lm $(LDLIBJPEG) $(LDLIBPNG) $(LDLIBTIFF) | ||
|
||
## | ||
# These statements add compiler flags to define USE_LIBJPEG, etc., | ||
# depending on which libraries have been specified above. | ||
ifneq ($(LDLIBJPEG),) | ||
CJPEG=-DUSE_LIBJPEG | ||
endif | ||
ifneq ($(LDLIBPNG),) | ||
CPNG=-DUSE_LIBPNG | ||
endif | ||
ifneq ($(LDLIBTIFF),) | ||
CTIFF=-DUSE_LIBTIFF | ||
endif | ||
|
||
ALLCFLAGS=$(CFLAGS) $(CJPEG) $(CPNG) $(CTIFF) | ||
|
||
LIBIPOL_SOURCES=basic.c imageio.c | ||
|
||
ARCHIVENAME=$(LIBIPOLN)_$(shell date -u +%Y%m%d) | ||
SOURCES=basic.c basic.h imageio.c imageio.h LICENSE Makefile | ||
LIBIPOL_OBJECTS=$(LIBIPOL_SOURCES:.c=.o) | ||
.SUFFIXES: .c .o | ||
.PHONY: all clean rebuild dist dist-zip | ||
|
||
all: $(LIBIPOLN).$(LIBIPOLV) | ||
|
||
$(LIBIPOLN).$(LIBIPOLV): $(LIBIPOL_OBJECTS) | ||
$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $(LDLIBS) -s | ||
chmod -v 644 $@ | ||
mv $@ $@.$(LIBIPOLD) | ||
ln -s $@.$(LIBIPOLD) $@ | ||
ln -s $@ $(LIBIPOLN) | ||
|
||
.c.o: | ||
$(CC) -c $(ALLCFLAGS) $< -o $@ | ||
|
||
clean: | ||
-$(RM) $(LIBIPOL_OBJECTS) $(LIBIPOLN)* | ||
|
||
rebuild: clean all | ||
dist: $(SOURCES) | ||
-rm -rf $(ARCHIVENAME) | ||
mkdir $(ARCHIVENAME) | ||
ln $(SOURCES) $(ARCHIVENAME) | ||
tar vchzf $(ARCHIVENAME).tgz $(ARCHIVENAME) | ||
-rm -rf $(ARCHIVENAME) | ||
|
||
dist-zip: $(SOURCES) | ||
-rm -rf $(ARCHIVENAME) | ||
mkdir $(ARCHIVENAME) | ||
ln $(SOURCES) $(ARCHIVENAME) | ||
-rm -f $(ARCHIVENAME).zip | ||
zip -r9 $(ARCHIVENAME).zip $(ARCHIVENAME)/* | ||
-rm -rf $(ARCHIVENAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
% IPOL.IM Library Image Input-Output. | ||
|
||
# ABOUT | ||
|
||
* Author : Pascal Getreuer <getreuer@gmail.com> | ||
* Copyright : (C) 2010-2012 IPOL Image Processing On Line http://www.ipol.im/ | ||
* Licence : BSD | ||
* Latest version available at: https://github.com/zvezdochiot/libipoliio | ||
|
||
# OVERVIEW | ||
|
||
This source code provides an implementation of the "Image Input-Output" | ||
described in the IPOL article: http://www.ipol.im/ | ||
|
||
# UNIX/LINUX/MAC USER GUIDE | ||
|
||
The code is compilable on Unix/Linux and Mac OS. | ||
|
||
- Compilation. | ||
Automated compilation requires the make. | ||
|
||
- Dependencies. | ||
This code requires the libpng, libtiff, libjpeg. | ||
|
||
- Image formats. | ||
Only the BMP, PNG, JPEG, and TIFF (float) formats are supported. | ||
|
||
------------------------------------------------------------------------- | ||
Usage: | ||
1. Download the code package and extract it. Go to that directory. | ||
|
||
2. Compile the source code (on Unix/Linux/Mac OS). | ||
|
||
make; | ||
|
||
# ABOUT THIS FILE | ||
This program is free software: you can use, modify and/or | ||
redistribute it under the terms of the simplified BSD License. You | ||
should have received a copy of this license along this program. If | ||
not, see <http://www.opensource.org/licenses/bsd-license.html>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.20130706 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* @file basic.c | ||
* @brief Memory management, portable types, math constants, and timing | ||
* @author Pascal Getreuer <getreuer@gmail.com> | ||
* | ||
* This file implements a function Clock, a timer with millisecond | ||
* precision. In order to obtain timing at high resolution, platform- | ||
* specific functions are needed: | ||
* | ||
* - On Windows systems, the GetSystemTime function is used. | ||
* - On POSIX systems, the gettimeofday function is used. | ||
* | ||
* Otherwise as a fallback, time.h time is used, and in this case Clock has | ||
* only second accuracy. This file attempts to detect whether the platform | ||
* is POSIX or Windows and defines Clock accordingly. A particular | ||
* implementation can be forced by defining USE_GETSYSTEMTIME, | ||
* USE_GETTIMEOFDAY, or USE_TIME. | ||
* | ||
* | ||
* Copyright (c) 2010-2011, Pascal Getreuer | ||
* All rights reserved. | ||
* | ||
* This program is free software: you can use, modify and/or | ||
* redistribute it under the terms of the simplified BSD License. You | ||
* should have received a copy of this license along this program. If | ||
* not, see <http://www.opensource.org/licenses/bsd-license.html>. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdarg.h> | ||
#include "basic.h" | ||
|
||
|
||
/* Autodetect whether to use Windows, POSIX, | ||
or fallback implementation for Clock. */ | ||
#if !defined(USE_GETSYSTEMTIME) && !defined(USE_GETTIMEOFDAY) && !defined(USE_TIME) | ||
# if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) | ||
# define USE_GETSYSTEMTIME | ||
# elif defined(unix) || defined(__unix__) || defined(__unix) | ||
# include <unistd.h> | ||
# if (_POSIX_TIMERS) || (_POSIX_VERSION >= 200112L) | ||
# define USE_GETTIMEOFDAY | ||
# endif | ||
# endif | ||
#endif | ||
|
||
/* Define Clock(), get the system clock in milliseconds */ | ||
#if defined(USE_GETSYSTEMTIME) | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
|
||
unsigned long Clock() /* Windows implementation */ | ||
{ | ||
static SYSTEMTIME TimeVal; | ||
GetSystemTime(&TimeVal); | ||
return (unsigned long)((unsigned long)TimeVal.wMilliseconds | ||
+ 1000*((unsigned long)TimeVal.wSecond | ||
+ 60*((unsigned long)TimeVal.wMinute | ||
+ 60*((unsigned long)TimeVal.wHour | ||
+ 24*(unsigned long)TimeVal.wDay)))); | ||
} | ||
#elif defined(USE_GETTIMEOFDAY) | ||
#include <unistd.h> | ||
#include <sys/time.h> | ||
|
||
unsigned long Clock() /* POSIX implementation */ | ||
{ | ||
struct timeval TimeVal; | ||
gettimeofday(&TimeVal, NULL); | ||
return (unsigned long)(TimeVal.tv_usec/1000 + TimeVal.tv_sec*1000); | ||
} | ||
#else | ||
#include <time.h> | ||
|
||
unsigned long Clock() /* Fallback implementation */ | ||
{ | ||
time_t RawTime; | ||
struct tm *TimeVal; | ||
time(&RawTime); | ||
TimeVal = localtime(&RawTime); | ||
return (unsigned long)(1000*((unsigned long)TimeVal->tm_sec | ||
+ 60*((unsigned long)TimeVal->tm_min | ||
+ 60*((unsigned long)TimeVal->tm_hour | ||
+ 24*(unsigned long)TimeVal->tm_mday)))); | ||
} | ||
#endif | ||
|
||
|
||
/** @brief malloc with an error message on failure. */ | ||
void *MallocWithErrorMessage(size_t Size) | ||
{ | ||
void *Ptr; | ||
|
||
if(!(Ptr = malloc(Size))) | ||
ErrorMessage("Memory allocation of %u bytes failed.\n", Size); | ||
|
||
return Ptr; | ||
} | ||
|
||
|
||
/** @brief realloc with an error message and free on failure. */ | ||
void *ReallocWithErrorMessage(void *Ptr, size_t Size) | ||
{ | ||
void *NewPtr; | ||
|
||
if(!(NewPtr = realloc(Ptr, Size))) | ||
{ | ||
ErrorMessage("Memory reallocation of %u bytes failed.\n", Size); | ||
Free(Ptr); /* Free the previous block on failure */ | ||
} | ||
|
||
return NewPtr; | ||
} | ||
|
||
|
||
/** @brief Redefine this function to customize error messages. */ | ||
void ErrorMessage(const char *Format, ...) | ||
{ | ||
va_list Args; | ||
|
||
va_start(Args, Format); | ||
/* Write a formatted error message to stderr */ | ||
vfprintf(stderr, Format, Args); | ||
va_end(Args); | ||
} |
Oops, something went wrong.