Skip to content

Commit

Permalink
Adds Image-Resampler libarary.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Oct 16, 2021
1 parent ee623c1 commit d47bd90
Show file tree
Hide file tree
Showing 38 changed files with 6,426 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Building The Project](#building-the-project)
- [Installing The Game](#installing-the-game)
- [Running The Game](#running-the-game)
- [Third Party Libraries](#third-party-libraries)
- [Anti-virus Warning](#anti-virus-warning)
- [Legal](#legal)
- [License](#license)
Expand Down Expand Up @@ -66,6 +67,11 @@ You can download the v2.03 patch in English, French, German and Spanish.<br>
# Running The Game
Copy the built executables from the build directory to the Tiberian Sun directory. Run `LaunchVinifera.exe` to start the game with the Vinifera project applied. For more information on how to use Vinifera, please read the documention or you can join the **C&C Modding Haven** [Discord server](<https://discord.gg/sZeMzz6qVg>) and use the **#vinifera-chat** channel.

# Third-Party Libraries
Vinifera makes use of third-party libraries to help implement features. Below is a list of libraries used by the project;
- [LodePNG](https://lodev.org/lodepng/)
- [Image-Resampler](https://github.com/ramenhut/image-resampler)

# Anti-virus Warning
Anti-virus software like Windows Defender could mark the binaries built from the DLL configuration in this project as a virus. We would like to assure that this is a false-positive and that these is completely safe to use. If you are still unsure about running these binaries on your system, your are welcome to join our Discord server where one of the developers can explain the process used by this project in detail.

Expand Down
231 changes: 231 additions & 0 deletions src/libs/image-resampler/Base/vnBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@

// Copyright (c) 1998-2009 Joe Bertolami. All Right Reserved.
//
// vnBase.h
//
// 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 HOLDER 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.
//
// Additional Information:
//
// For more information, visit http://www.bertolami.com.

#ifndef __VN_BASE_H__
#define __VN_BASE_H__

/**********************************************************************************
//
// Platform definitions
//
**********************************************************************************/

#if defined ( _WIN32 ) || defined ( _WIN64 )
#include "windows.h"
#pragma warning (disable : 4244) // conversion, possible loss of data
#pragma warning (disable : 4018) // signed / unsigned mismatch
#pragma warning (disable : 4996) // deprecated interfaces
#pragma warning (disable : 4221) // empty translation unit
#pragma warning (disable : 4273) // inconsistent linkage

#define VN_PLATFORM_WINDOWS // building a Windows application

#elif defined ( __APPLE__ )
#include "TargetConditionals.h"
#include "unistd.h"
#include "sys/types.h"
#include "ctype.h"

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define VN_PLATFORM_IOS // building an application for iOS
#elif TARGET_OS_MAC
#define VN_PLATFORM_MACOSX // building a Mac OSX application
#endif
#else
#error "Unsupported target platform detected."
#endif

/**********************************************************************************
//
// Debug definitions
//
**********************************************************************************/

#if defined ( VN_PLATFORM_WINDOWS )
#ifdef _DEBUG
#define VN_DEBUG _DEBUG
#elif defined ( DEBUG )
#define VN_DEBUG DEBUG
#endif
#if defined( VN_DEBUG ) && !defined( debug_break )
#define debug_break __debugbreak
#endif
#define __VN_FUNCTION__ __FUNCTION__
#elif defined ( VN_PLATFORM_IOS ) || defined ( VN_PLATFORM_MACOSX )
#ifdef DEBUG
#define VN_DEBUG DEBUG
#if !defined( debug_break )
#define debug_break() __builtin_trap()
#endif
#endif
#define __VN_FUNCTION__ __func__
#endif

/**********************************************************************************
//
// Standard headers
//
**********************************************************************************/

#include "stdio.h"
#include "stdlib.h"
#include "stdarg.h"
#include "string.h"
#include "math.h"

/**********************************************************************************
//
// Standard types
//
**********************************************************************************/

#if defined ( VN_PLATFORM_WINDOWS )
// Types are already defined by the platform.
#elif defined ( VN_PLATFORM_IOS ) || defined ( VN_PLATFORM_MACOSX )
typedef int64_t INT64;
typedef int32_t INT32;
typedef int16_t INT16;
typedef int8_t INT8;

typedef u_int64_t UINT64;
typedef u_int32_t UINT32;
typedef u_int16_t UINT16;
typedef u_int8_t UINT8;
#endif

typedef float FLOAT32;
typedef double FLOAT64;
typedef wchar_t WCHAR;

#define VN_KB ( (UINT32) 1024 )
#define VN_MB ( VN_KB * VN_KB )
#define VN_GB ( VN_MB * VN_KB )

#define CONST const
#ifndef CHAR
#define CHAR char
#endif

/**********************************************************************************
//
// Status codes
//
**********************************************************************************/

typedef UINT8 VN_STATUS;

#define VN_SUCCESS (0)
#define VN_ERROR_INVALIDARG (1)
#define VN_ERROR_NOTIMPL (2)
#define VN_ERROR_OUTOFMEMORY (3)
#define VN_ERROR_UNDEFINED (4)
#define VN_ERROR_HARDWAREFAIL (5)
#define VN_ERROR_INVALID_INDEX (6)
#define VN_ERROR_CAPACITY_LIMIT (7)
#define VN_ERROR_INVALID_RESOURCE (8)
#define VN_ERROR_OPERATION_TIMEDOUT (9)
#define VN_ERROR_EXECUTION_FAILURE (10)
#define VN_ERROR_PERMISSION_DENIED (11)
#define VN_ERROR_IO_FAILURE (12)
#define VN_ERROR_RESOURCE_UNREACHABLE (13)
#define VN_ERROR_SYSTEM_FAILURE (14)
#define VN_ERROR_NOT_READY (15)
#define VN_ERROR_OPERATION_COMPLETED (16)
#define VN_ERROR_RESOURCE_UNUSED (17)

#define VN_SUCCEEDED( code ) ( (code) == VN_SUCCESS )
#define VN_FAILED( code ) ( !VN_SUCCEEDED( code ) )

/**********************************************************************************
//
// Debug support
//
**********************************************************************************/

#ifdef VN_DEBUG
#define VN_PARAM_CHECK (1)
#define VN_ERR(fmt, ...) do { printf("[VN-ERR] "); \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); debug_break(); \
} while(0)

#define VN_MSG(fmt, ...) do { printf("[VN-MSG] "); \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); \
} while(0)
#else
#define VN_PARAM_CHECK (0)
#define VN_ERR(fmt, ...)
#define VN_MSG(fmt, ...) do { printf("[VN-MSG] "); \
printf(fmt, ##__VA_ARGS__); \
printf("\n"); \
} while(0)
#endif

#define VN_ERROR_CREATE_STRING(x) ((char *) #x)
#define vnPostError(x) vnPostErrorInternal(x, VN_ERROR_CREATE_STRING(x), __VN_FUNCTION__, (char *) __FILE__, __LINE__)
inline UINT32 vnPostErrorInternal(UINT8 error, CONST CHAR *error_string, CONST CHAR *function, CONST CHAR *filename, UINT32 line)
{
#ifdef VN_DEBUG
CONST CHAR *path = filename;

for (INT32 i = (INT32) strlen(filename); i >= 0; --i)
{
if (filename[ i ] == '/')
break;

path = &filename[i];
}

VN_ERR("*** RIP *** %s @ %s in %s:%i", error_string, function, path, line);
#endif
return error;
}

/**********************************************************************************
//
// Standard helpers
//
**********************************************************************************/

#define VN_DISABLE_COPY_AND_ASSIGN(type) \
type(const type &rvalue); \
type &operator = (const type &rvalue);

#define VN_TEMPLATE_T template <class T>
#define VN_TEMPLATE_SPEC template <>

#define VN_VARG(fmt) va_list argptr; \
CHAR text[1*VN_KB] = {0}; \
va_start(argptr, fmt); \
vsprintf(text, fmt, argptr); \
va_end(argptr);

#endif // __VN_BASE_H__
Loading

0 comments on commit d47bd90

Please sign in to comment.