Browse Source

(committing very old stuff) Dunno

master
Joshua Moerman 8 years ago
parent
commit
9f8b8f38a7
  1. 5
      AwesomeAttractorND.xcodeproj/project.pbxproj
  2. 4
      AwesomeAttractorND/Canvas.hpp
  3. 2
      AwesomeAttractorND/Image.hpp
  4. 107
      AwesomeAttractorND/ImageFormatPNG.hpp
  5. 4
      AwesomeAttractorND/main.cpp

5
AwesomeAttractorND.xcodeproj/project.pbxproj

@ -7,7 +7,6 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 42D2E1221456175C00FBC16A /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42D2E1211456175C00FBC16A /* main.cpp */; };
42D2E1241456175C00FBC16A /* AwesomeAttractorND.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */; }; 42D2E1241456175C00FBC16A /* AwesomeAttractorND.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -35,7 +34,6 @@
42C2D1621461E562001BF28D /* array.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = array.hpp; sourceTree = "<group>"; }; 42C2D1621461E562001BF28D /* array.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = array.hpp; sourceTree = "<group>"; };
42D0F939146E7F6A002B1025 /* ImageFormatBMP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatBMP.hpp; sourceTree = "<group>"; }; 42D0F939146E7F6A002B1025 /* ImageFormatBMP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatBMP.hpp; sourceTree = "<group>"; };
42D0F93B146E805D002B1025 /* ImageFormatPNG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatPNG.hpp; sourceTree = "<group>"; }; 42D0F93B146E805D002B1025 /* ImageFormatPNG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatPNG.hpp; sourceTree = "<group>"; };
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; }; 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 = "<group>"; }; 42D2E1211456175C00FBC16A /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = AwesomeAttractorND.1; sourceTree = "<group>"; }; 42D2E1231456175C00FBC16A /* AwesomeAttractorND.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = AwesomeAttractorND.1; sourceTree = "<group>"; };
@ -46,7 +44,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
42D0F93D146E8A95002B1025 /* libpng.dylib in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -56,7 +53,6 @@
42D2E1121456175C00FBC16A = { 42D2E1121456175C00FBC16A = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
42D0F93C146E8A95002B1025 /* libpng.dylib */,
42D2E1201456175C00FBC16A /* AwesomeAttractorND */, 42D2E1201456175C00FBC16A /* AwesomeAttractorND */,
42D2E11E1456175C00FBC16A /* Products */, 42D2E11E1456175C00FBC16A /* Products */,
); );
@ -114,6 +110,7 @@
42D2E1141456175C00FBC16A /* Project object */ = { 42D2E1141456175C00FBC16A /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0420;
ORGANIZATIONNAME = Vadovas; ORGANIZATIONNAME = Vadovas;
}; };
buildConfigurationList = 42D2E1171456175C00FBC16A /* Build configuration list for PBXProject "AwesomeAttractorND" */; buildConfigurationList = 42D2E1171456175C00FBC16A /* Build configuration list for PBXProject "AwesomeAttractorND" */;

4
AwesomeAttractorND/Canvas.hpp

@ -44,8 +44,8 @@ public:
const size_t width = size<0>(); const size_t width = size<0>();
const size_t height = size<1>(); const size_t height = size<1>();
const size_t c = 0.5*position[0]*width + width*.5; const size_t c = 0.5*(0.3*position[0])*width + width*.5;
const size_t r = 0.5*position[1]*width + height*.5; const size_t r = 0.5*(0.3*position[1])*width + height*.5;
if(c < width && r < height) { if(c < width && r < height) {
storage[r][c]++; storage[r][c]++;

2
AwesomeAttractorND/Image.hpp

@ -10,6 +10,6 @@
#define AwesomeAttractorND_Image_hpp #define AwesomeAttractorND_Image_hpp
#include "ImageFormatBMP.hpp" #include "ImageFormatBMP.hpp"
#include "ImageFormatPNG.hpp" //#include "ImageFormatPNG.hpp"
#endif #endif

107
AwesomeAttractorND/ImageFormatPNG.hpp

@ -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 <stdio.h>
#include <stdexcept>
#include <png.h>
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<unsigned char const*>(row.data()));
x = 0;
}
return *this;
}
private:
FILE* fp;
png_structp png_ptr;
png_infop info_ptr;
std::vector<pixel> row;
uint32_t x;
};
}
}
#endif

4
AwesomeAttractorND/main.cpp

@ -49,7 +49,7 @@ void output(Canvas const & canvas){
Tonemappers::GammaCorrector tonemapper; Tonemappers::GammaCorrector tonemapper;
tonemapper.analyse(canvas); 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); tonemapper.process(canvas, image);
} }
@ -58,7 +58,7 @@ int main (int, const char * []){
l.start("all"); l.start("all");
l.log("creating canvas"); l.log("creating canvas");
Canvas canvas(8000, 8000); Canvas canvas(4000, 4000);
l.log("filling canvas"); l.log("filling canvas");
fill(canvas); fill(canvas);
l.log("outputting canvas"); l.log("outputting canvas");