JWS C Library
C language utility library
image.h
Go to the documentation of this file.
00001 /*
00002  * This work is licensed under a Creative Commons 
00003  * Attribution-Noncommercial-Share Alike 3.0 United States License.
00004  * 
00005  *    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
00006  * 
00007  * You are free:
00008  * 
00009  *    to Share - to copy, distribute, display, and perform the work
00010  *    to Remix - to make derivative works
00011  * 
00012  * Under the following conditions:
00013  * 
00014  *    Attribution. You must attribute the work in the manner specified by the
00015  *    author or licensor (but not in any way that suggests that they endorse you
00016  *    or your use of the work).
00017  * 
00018  *    Noncommercial. You may not use this work for commercial purposes.
00019  * 
00020  *    Share Alike. If you alter, transform, or build upon this work, you may
00021  *    distribute the resulting work only under the same or similar license to
00022  *    this one.
00023  * 
00024  * For any reuse or distribution, you must make clear to others the license
00025  * terms of this work. The best way to do this is by including this header.
00026  * 
00027  * Any of the above conditions can be waived if you get permission from the
00028  * copyright holder.
00029  * 
00030  * Apart from the remix rights granted under this license, nothing in this
00031  * license impairs or restricts the author's moral rights.
00032  */
00033 
00034 
00052 #ifndef IMAGE_H
00053 #define IMAGE_H
00054 
00055 
00056 #include <jwsc/config.h>
00057 
00058 #include <stdlib.h>
00059 #include <inttypes.h>
00060 
00061 #include "jwsc/base/error.h"
00062 #include "jwsc/matrix/matrix.h"
00063 
00064 
00065 #ifdef __cplusplus
00066 namespace jwsc {
00067 extern "C" {
00068 #endif
00069 
00070 
00076 typedef struct Pixel_f
00077 {
00079     float r;
00080 
00082     float g;
00083 
00085     float b;
00086 } 
00087 Pixel_f;
00088 
00089 
00090 
00091 
00093 typedef struct Image_f
00094 {
00096     uint32_t num_rows;
00097 
00099     uint32_t num_cols;
00100 
00102     Pixel_f** pxls;
00103 } 
00104 Image_f;
00105 
00106 
00107 
00108 
00117 void create_image_f
00118 (
00119     Image_f** img_out, 
00120     uint32_t  num_rows, 
00121     uint32_t  num_cols
00122 );
00123 
00137 void create_init_image_f
00138 (
00139     Image_f** img_out, 
00140     uint32_t  num_rows, 
00141     uint32_t  num_cols,
00142     Pixel_f   val
00143 );
00144 
00161 void create_zero_image_f
00162 (
00163     Image_f** img_out, 
00164     uint32_t  num_rows, 
00165     uint32_t  num_cols
00166 );
00167 
00184 void create_random_image_f
00185 (
00186     Image_f** img_out, 
00187     uint32_t  num_rows, 
00188     uint32_t  num_cols,
00189     Pixel_f   min,
00190     Pixel_f   max
00191 );
00192 
00208 Error* create_image_from_matrices_f
00209 (
00210     Image_f**   img_out, 
00211     const Matrix_f* m_r,
00212     const Matrix_f* m_g,
00213     const Matrix_f* m_b
00214 );
00215 
00232 void create_image_from_matrix_f
00233 (
00234     Image_f**       img_out, 
00235     const Matrix_f* m
00236 );
00237 
00254 void create_matrices_from_image_f
00255 (
00256     Matrix_f**     m_r_out, 
00257     Matrix_f**     m_g_out, 
00258     Matrix_f**     m_b_out, 
00259     const Image_f* img
00260 );
00261 
00278 void create_matrix_from_image_f
00279 (
00280     Matrix_f**     m_out, 
00281     const Image_f* img,
00282     float          r_weight,
00283     float          g_weight,
00284     float          b_weight
00285 );
00286 
00300 void copy_image_f(Image_f** img_out, const Image_f* img_in);
00301 
00315 void free_image_f(Image_f* img);
00316 
00320 #ifdef __cplusplus
00321 }
00322 }
00323 #endif
00324 
00325 
00326 #endif