erebus
diff liberebus/src/image.inl @ 2:474a0244f57d
fixed specialization mistake
fixed line endings
added makefiles
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 28 Apr 2014 06:31:10 +0300 |
parents | 4abdce1361b9 |
children | c8a6fb04fefa |
line diff
1.1 --- a/liberebus/src/image.inl Mon Apr 28 05:58:22 2014 +0300 1.2 +++ b/liberebus/src/image.inl Mon Apr 28 06:31:10 2014 +0300 1.3 @@ -118,7 +118,14 @@ 1.4 return pixels; 1.5 } 1.6 1.7 -bool Image<unsigned char>::load(const char *fname) 1.8 +template <typename T> 1.9 +inline bool load_image(Image<T> *img, const char *fname) 1.10 +{ 1.11 + return false; 1.12 +} 1.13 + 1.14 +template <> 1.15 +inline bool load_image<unsigned char>(Image<unsigned char> *img, const char *fname) 1.16 { 1.17 int xsz, ysz; 1.18 unsigned char *pix = (unsigned char*)img_load_pixels(fname, &xsz, &ysz, IMG_FMT_RGBA32); 1.19 @@ -126,11 +133,13 @@ 1.20 return false; 1.21 } 1.22 1.23 - create(xsz, ysz, pix); 1.24 + img->create(xsz, ysz, pix); 1.25 + img_free_pixels(pix); 1.26 return true; 1.27 } 1.28 1.29 -bool Image<float>::load(const char *fname) 1.30 +template <> 1.31 +inline bool load_image<float>(Image<float> *img, const char *fname) 1.32 { 1.33 int xsz, ysz; 1.34 float *pix = (float*)img_load_pixels(fname, &xsz, &ysz, IMG_FMT_RGBAF); 1.35 @@ -138,6 +147,13 @@ 1.36 return false; 1.37 } 1.38 1.39 - create(xsz, ysz, pix); 1.40 + img->create(xsz, ysz, pix); 1.41 + img_free_pixels(pix); 1.42 return true; 1.43 -} 1.44 \ No newline at end of file 1.45 +} 1.46 + 1.47 +template <typename T> 1.48 +bool Image<T>::load(const char *fname) 1.49 +{ 1.50 + return load_image(this, fname); 1.51 +}