diff --git a/AwesomeAttractorND.xcodeproj/project.pbxproj b/AwesomeAttractorND.xcodeproj/project.pbxproj index fdd13e2..9e1c02d 100644 --- a/AwesomeAttractorND.xcodeproj/project.pbxproj +++ b/AwesomeAttractorND.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 42D0F93D146E8A95002B1025 /* libpng.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 42D0F93C146E8A95002B1025 /* libpng.dylib */; }; 42D2E1221456175C00FBC16A /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42D2E1211456175C00FBC16A /* main.cpp */; }; 42D2E1241456175C00FBC16A /* AwesomeAttractorND.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */; }; /* End PBXBuildFile section */ @@ -35,7 +34,6 @@ 42C2D1621461E562001BF28D /* array.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = array.hpp; sourceTree = ""; }; 42D0F939146E7F6A002B1025 /* ImageFormatBMP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatBMP.hpp; sourceTree = ""; }; 42D0F93B146E805D002B1025 /* ImageFormatPNG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatPNG.hpp; sourceTree = ""; }; - 42D0F93C146E8A95002B1025 /* libpng.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpng.dylib; path = usr/local/lib/libpng.dylib; sourceTree = SDKROOT; }; 42D2E11D1456175C00FBC16A /* AwesomeAttractorND */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = AwesomeAttractorND; sourceTree = BUILT_PRODUCTS_DIR; }; 42D2E1211456175C00FBC16A /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = AwesomeAttractorND.1; sourceTree = ""; }; @@ -46,7 +44,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 42D0F93D146E8A95002B1025 /* libpng.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -56,7 +53,6 @@ 42D2E1121456175C00FBC16A = { isa = PBXGroup; children = ( - 42D0F93C146E8A95002B1025 /* libpng.dylib */, 42D2E1201456175C00FBC16A /* AwesomeAttractorND */, 42D2E11E1456175C00FBC16A /* Products */, ); @@ -114,6 +110,7 @@ 42D2E1141456175C00FBC16A /* Project object */ = { isa = PBXProject; attributes = { + LastUpgradeCheck = 0420; ORGANIZATIONNAME = Vadovas; }; buildConfigurationList = 42D2E1171456175C00FBC16A /* Build configuration list for PBXProject "AwesomeAttractorND" */; diff --git a/AwesomeAttractorND/Canvas.hpp b/AwesomeAttractorND/Canvas.hpp index 8fa16e8..98becd0 100644 --- a/AwesomeAttractorND/Canvas.hpp +++ b/AwesomeAttractorND/Canvas.hpp @@ -44,8 +44,8 @@ public: const size_t width = size<0>(); const size_t height = size<1>(); - const size_t c = 0.5*position[0]*width + width*.5; - const size_t r = 0.5*position[1]*width + height*.5; + const size_t c = 0.5*(0.3*position[0])*width + width*.5; + const size_t r = 0.5*(0.3*position[1])*width + height*.5; if(c < width && r < height) { storage[r][c]++; diff --git a/AwesomeAttractorND/Image.hpp b/AwesomeAttractorND/Image.hpp index e837571..d24fa6f 100644 --- a/AwesomeAttractorND/Image.hpp +++ b/AwesomeAttractorND/Image.hpp @@ -10,6 +10,6 @@ #define AwesomeAttractorND_Image_hpp #include "ImageFormatBMP.hpp" -#include "ImageFormatPNG.hpp" +//#include "ImageFormatPNG.hpp" #endif diff --git a/AwesomeAttractorND/ImageFormatPNG.hpp b/AwesomeAttractorND/ImageFormatPNG.hpp deleted file mode 100644 index 08c0b4e..0000000 --- a/AwesomeAttractorND/ImageFormatPNG.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// -// ImageFormatPNG.hpp -// AwesomeAttractorND -// -// Created by Joshua Moerman on 11/12/11. -// Copyright 2011 Vadovas. All rights reserved. -// - -#ifndef AwesomeAttractorND_ImageFormatPNG_hpp -#define AwesomeAttractorND_ImageFormatPNG_hpp - -#include -#include -#include - -namespace ImageFormats { - namespace png{ - struct pixel { - pixel() - : red(0) - , green(0) - , blue(0) - {} - - pixel(double red, double green, double blue) - : red(clamp(255*red)) - , green(clamp(255*green)) - , blue(clamp(255*blue)) - {} - - pixel(int red, int green, int blue) - : red(clamp(red)) - , green(clamp(green)) - , blue(clamp(blue)) - {} - - void swapRB(){ - std::swap(red, blue); - } - - private: - uint8_t clamp(int n){ - return std::min(255, std::max(0, n)); - } - - uint8_t red; - uint8_t green; - uint8_t blue; - }; - - struct png_stream{ - typedef pixel pixel; - - png_stream(uint32_t width, uint32_t height, std::string filename) - : fp(0) - , png_ptr(0) - , info_ptr(0) - , row(width) - , x(0) - { - fp = fopen(filename.c_str(), "wb"); - if(!fp) throw std::runtime_error("Could not open file"); - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); - if(!png_ptr) throw std::runtime_error("PNG structure could not be allocated"); - - info_ptr = png_create_info_struct(png_ptr); - if(!info_ptr) throw std::runtime_error("PNG information structure could not be allocated"); - - png_init_io(png_ptr, fp); - - png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - png_set_compression_level(png_ptr, 9); - - png_write_info(png_ptr, info_ptr); - } - - ~png_stream(){ - png_write_end(png_ptr, info_ptr); - png_destroy_info_struct(png_ptr, &info_ptr); - fclose(fp); - } - - png_stream& operator<<(pixel const & p){ - row[x] = p; - ++x; - if(x >= row.size()){ - png_write_row(png_ptr, reinterpret_cast(row.data())); - x = 0; - } - - return *this; - } - - private: - FILE* fp; - png_structp png_ptr; - png_infop info_ptr; - - std::vector row; - uint32_t x; - }; - } -} - -#endif diff --git a/AwesomeAttractorND/main.cpp b/AwesomeAttractorND/main.cpp index 50c4231..46635b3 100644 --- a/AwesomeAttractorND/main.cpp +++ b/AwesomeAttractorND/main.cpp @@ -49,7 +49,7 @@ void output(Canvas const & canvas){ Tonemappers::GammaCorrector tonemapper; tonemapper.analyse(canvas); - ImageFormats::png::png_stream image(canvas.size<0>(), canvas.size<1>(), "test.png"); + ImageFormats::bmp::bitmap_stream<> image(canvas.size<0>(), canvas.size<1>(), "test.bmp"); tonemapper.process(canvas, image); } @@ -58,7 +58,7 @@ int main (int, const char * []){ l.start("all"); l.log("creating canvas"); - Canvas canvas(8000, 8000); + Canvas canvas(4000, 4000); l.log("filling canvas"); fill(canvas); l.log("outputting canvas");