Project

General

Profile

« Previous | Next » 

Revision 2243e528

Added by David Sorber almost 8 years ago

Started making a simple test program.

View differences:

software/packJPG_library/lib_src/CMakeLists.txt
project("packJPG")
cmake_minimum_required(VERSION 3.2)
include_directories(.)
set(CMAKE_CXX_STANDARD 14)
include_directories(..)
set(packjpg_sources
../aricoder.cpp
......
add_library(packjpg SHARED
${packjpg_sources})
find_package(Boost 1.54.0
REQUIRED
COMPONENTS filesystem)
add_executable(packjpg_simple
../bin/packjpg_simple.cc)
target_link_libraries(packjpg_simple ${Boost_LIBRARIES} packjpg stdc++fs)
software/packJPG_library/lib_src/bin/packjpg_simple.cc
#include <cstdint>
#include <fstream>
#include <iostream>
#include <vector>
#include <boost/filesystem.hpp>
#include "../packjpg.h"
namespace bfs = boost::filesystem;
int main(int argc, char** argv)
{
std::cout << "packJPG Simple Test Utility" << std::endl;
std::cout << " [" << packJPG::pjglib_version_info() << "]\n" << std::endl;
// Verify that input was provided
if (argc < 2)
{
std::cerr << "ERROR: please provide an input file\n" << std::endl;
return -1;
}
char* file_path = argv[1];
// Verify that input is a path to a file
if (! bfs::is_regular_file(file_path))
{
std::cerr << "ERROR: \"" << file_path << "\" is not a file\n" << std::endl;
return -1;
}
uint32_t file_size = bfs::file_size(file_path);
std::cout << "File size: " << file_size << std::endl;
std::vector<char>* file_buffer = new std::vector<char>(file_size);
std::ifstream input_stream(file_path, std::ios::binary | std::ios::in);
if (! input_stream)
{
std::cerr << "ERROR: unable to read from \"" << file_path << "\""
<< std::endl;
return -1;
}
input_stream.read(file_buffer->data(), file_size);
input_stream.close();
//~ packJPG instance = packJPG();
delete file_buffer;
return 0;
}
software/packJPG_library/lib_src/packjpg.cpp
#include <stdexcept>
#include <vector>
#include "bitops.h"
#include "aricoder.h"
#include "pjpgtbl.h"
#include "dct8x8.h"
#include "packjpg.h"
software/packJPG_library/lib_src/packjpg.h
#ifndef PACKJPG_H
#define PACKJPG_H
#include "bitops.h"
#include "aricoder.h"
#include "pjpgtbl.h"
#include "dct8x8.h"
#define MEM_ERRMSG "out of memory error"
#define FRD_ERRMSG "could not read file / file not found: %s"

Also available in: Unified diff