volmetrics

diff src/volume.cc @ 3:927c29b93009

added image.cc
author Eleni Maria Stea <elene.mst@gmail.com>
date Sat, 11 Jan 2014 22:55:27 +0200
parents 88d390af583f
children 1fbbe10c8e08
line diff
     1.1 --- a/src/volume.cc	Sat Jan 11 18:00:02 2014 +0200
     1.2 +++ b/src/volume.cc	Sat Jan 11 22:55:27 2014 +0200
     1.3 @@ -1,65 +1,1 @@
     1.4 -#include <imago2.h>
     1.5 -
     1.6 -#include "image.h"
     1.7 -
     1.8 -Image::Image()
     1.9 -{
    1.10 -	pixels = 0;
    1.11 -	width = 0;
    1.12 -	height = 0;
    1.13 -}
    1.14 -
    1.15 -Image::~Image()
    1.16 -{
    1.17 -	delete [] pixels;
    1.18 -}
    1.19 -
    1.20 -bool Image::load(const char *fname)
    1.21 -{
    1.22 -	int new_width, new_height;
    1.23 -	float *new_pixels = (float*)img_load_pixels(fname, &new_width, &new_height, IMG_FMT_GREYF);
    1.24 -
    1.25 -	if(!new_pixels) {
    1.26 -		fprintf(stderr, "Failed to load image: %s\n", fname);
    1.27 -		return false;
    1.28 -	}
    1.29 -
    1.30 -	set_pixels(new_pixels, new_width, new_height);
    1.31 -	img_free_pixels(new_pixels);
    1.32 -	return true;
    1.33 -}
    1.34 -
    1.35 -float *Image::get_pixels()
    1.36 -{
    1.37 -	return pixels;
    1.38 -}
    1.39 -
    1.40 -const float *Image::get_pixels() const
    1.41 -{
    1.42 -	return pixels;
    1.43 -}
    1.44 -
    1.45 -void Image::set_pixels(const float *pixels, int width, int height)
    1.46 -{
    1.47 -	if(!pixels)
    1.48 -		return;
    1.49 -
    1.50 -	delete [] this->pixels;
    1.51 -
    1.52 -	this->pixels = new float[width * height];
    1.53 -	for(int i=0; i<width * height; i++) {
    1.54 -		this->pixels[i] = pixels[i];
    1.55 -	}
    1.56 -	this->width = width;
    1.57 -	this->height = height;
    1.58 -}
    1.59 -
    1.60 -int Image::get_width() const
    1.61 -{
    1.62 -	return width;
    1.63 -}
    1.64 -
    1.65 -int Image::get_height() const
    1.66 -{
    1.67 -	return height;
    1.68 -}
    1.69 +#include "volume.h"