Christian Heimke commited on 2011-07-15 09:08:32
Showing 22 changed files, with 716 additions and 41 deletions.
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -9,7 +9,6 @@ |
| 9 | 9 |
#include <stdlib.h> |
| 10 | 10 |
#include <string.h> |
| 11 | 11 |
|
| 12 |
-#include <BlinkenLib/BlinkenColorizer.h> |
|
| 13 | 12 |
#include <BlinkenLib/BlinkenLib.h> |
| 14 | 13 |
|
| 15 | 14 |
int main( int argCnt, char * * args ) |
| ... | ... |
@@ -22,7 +21,8 @@ int main( int argCnt, char * * args ) |
| 22 | 21 |
|
| 23 | 22 |
//print info |
| 24 | 23 |
printf( "BlinkenLib - BlinkenConv\n" |
| 25 |
- "version 0.5.5 date 2008-03-29\n" |
|
| 24 |
+ "version 0.6.0 date 2008-05-15\n" |
|
| 25 |
+ "config "BLINKENLIB_CONFIG"\n" |
|
| 26 | 26 |
"Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org>\n" |
| 27 | 27 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
| 28 | 28 |
"a blinkenarea.org project\n\n" ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -267,6 +267,32 @@ void BlinkenFrameSetColor( stBlinkenFrame * pFrame, int y, int x, unsigned long |
| 267 | 267 |
) / 255); |
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 |
+int BlinkenFrameIsEmpty( stBlinkenFrame * pFrame ) |
|
| 271 |
+//returns 1 if frame is empty (i.e. black), returns 0 otherwise |
|
| 272 |
+{
|
|
| 273 |
+ int y, x, c, i; |
|
| 274 |
+ |
|
| 275 |
+ if( pFrame == NULL ) |
|
| 276 |
+ return 0; |
|
| 277 |
+ |
|
| 278 |
+ for( y = 0; y < pFrame->height; y++ ) {
|
|
| 279 |
+ for( x = 0, i = 0; x < pFrame->width; x++ ) {
|
|
| 280 |
+ for( c = 0; c < pFrame->channels; c++, i++ ) {
|
|
| 281 |
+ if( pFrame->ppData[y][i] != 0 ) |
|
| 282 |
+ break; //pixel is not black -> abort |
|
| 283 |
+ } |
|
| 284 |
+ if( c < pFrame->channels ) |
|
| 285 |
+ break; |
|
| 286 |
+ } |
|
| 287 |
+ if( x < pFrame->width ) |
|
| 288 |
+ break; |
|
| 289 |
+ } |
|
| 290 |
+ if( y < pFrame->height ) |
|
| 291 |
+ return 0; //aborted somewhere -> at least ony pixel is not black |
|
| 292 |
+ else |
|
| 293 |
+ return 1; //not aborted -> all pixels are black |
|
| 294 |
+} |
|
| 295 |
+ |
|
| 270 | 296 |
int BlinkenFrameCompare( stBlinkenFrame * pFrame1, stBlinkenFrame * pFrame2 ) |
| 271 | 297 |
//returns -1 for frame1 smaller, 0 for equal, 1 for frame2 smaller |
| 272 | 298 |
{
|
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -34,6 +34,9 @@ void BlinkenFrameSetPixel( stBlinkenFrame * pFrame, int y, int x, int c, unsigne |
| 34 | 34 |
unsigned long BlinkenFrameGetColor( stBlinkenFrame * pFrame, int y, int x ); |
| 35 | 35 |
void BlinkenFrameSetColor( stBlinkenFrame * pFrame, int y, int x, unsigned long color ); |
| 36 | 36 |
|
| 37 |
+int BlinkenFrameIsEmpty( stBlinkenFrame * pFrame ); |
|
| 38 |
+//returns 1 if frame is empty (i.e. black), returns 0 otherwise |
|
| 39 |
+ |
|
| 37 | 40 |
int BlinkenFrameCompare( stBlinkenFrame * pFrame1, stBlinkenFrame * pFrame2 ); |
| 38 | 41 |
//returns -1 for frame1 smaller, 0 for equal, 1 for frame2 smaller |
| 39 | 42 |
|
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -8,6 +8,7 @@ |
| 8 | 8 |
#ifndef INC_BlinkenLib_BlinkenLib |
| 9 | 9 |
#define INC_BlinkenLib_BlinkenLib |
| 10 | 10 |
|
| 11 |
+#include <BlinkenLib/config.h> |
|
| 11 | 12 |
#include <BlinkenLib/BlinkenColorizer.h> |
| 12 | 13 |
#include <BlinkenLib/BlinkenMovie.h> |
| 13 | 14 |
#include <BlinkenLib/BlinkenFrame.h> |
| ... | ... |
@@ -0,0 +1,502 @@ |
| 1 |
+/* BlinkenLib |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 |
+ * Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
|
| 4 |
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
| 5 |
+ * a blinkenarea.org project |
|
| 6 |
+ */ |
|
| 7 |
+ |
|
| 8 |
+#include <stdio.h> |
|
| 9 |
+#include <stdlib.h> |
|
| 10 |
+#include <strings.h> |
|
| 11 |
+ |
|
| 12 |
+#include <zlib.h> |
|
| 13 |
+ |
|
| 14 |
+#define MNG_INCLUDE_WRITE_PROCS |
|
| 15 |
+#define MNG_ACCESS_CHUNKS |
|
| 16 |
+#define MNG_SUPPORT_READ |
|
| 17 |
+#define MNG_SUPPORT_DISPLAY |
|
| 18 |
+#define MNG_SUPPORT_WRITE |
|
| 19 |
+#include <libmng.h> |
|
| 20 |
+ |
|
| 21 |
+#include <BlinkenLib/config.h> |
|
| 22 |
+#include <BlinkenLib/BlinkenConstants.h> |
|
| 23 |
+#include <BlinkenLib/BlinkenFrame.h> |
|
| 24 |
+#include <BlinkenLib/BlinkenMovie.h> |
|
| 25 |
+#include <BlinkenLib/BlinkenMng.h> |
|
| 26 |
+ |
|
| 27 |
+// type for state of the MNG read/write process |
|
| 28 |
+typedef struct _BlMng_userdata {
|
|
| 29 |
+ FILE * hFile; // handle of open file |
|
| 30 |
+ unsigned int width; // size of canvas |
|
| 31 |
+ unsigned int height; |
|
| 32 |
+ unsigned char * canvas; // canvas (i.e. pixel data, size is height * width * 3) |
|
| 33 |
+ unsigned int counter_msec; // current number of milliseconds |
|
| 34 |
+ unsigned int timer_msec; // the MNG library will be called after this number of milliseconds |
|
| 35 |
+ stBlinkenMovie * movie; // movie being created |
|
| 36 |
+} BlMng_userdata; |
|
| 37 |
+ |
|
| 38 |
+mng_ptr BlMng_alloc( mng_size_t iSize ) |
|
| 39 |
+{
|
|
| 40 |
+ void * ptr = malloc( iSize ); |
|
| 41 |
+ if( ptr != NULL ) |
|
| 42 |
+ memset( ptr, 0, iSize ); |
|
| 43 |
+ return (mng_ptr)ptr; |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+void BlMng_free( mng_ptr pPtr, mng_size_t __attribute__(( unused )) iSize ) |
|
| 47 |
+{
|
|
| 48 |
+ free( pPtr ); |
|
| 49 |
+} |
|
| 50 |
+ |
|
| 51 |
+mng_bool BlMng_openstream( mng_handle __attribute__(( unused )) hMNG ) |
|
| 52 |
+{
|
|
| 53 |
+ return MNG_TRUE; |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+mng_bool BlMng_closestream( mng_handle __attribute__(( unused )) hMNG ) |
|
| 57 |
+{
|
|
| 58 |
+ return MNG_TRUE; |
|
| 59 |
+} |
|
| 60 |
+ |
|
| 61 |
+// read data from the open file |
|
| 62 |
+mng_bool BlMng_readdata( mng_handle hMNG, mng_ptr pBuf, mng_uint32 iSize, mng_uint32 * iRead ) |
|
| 63 |
+{
|
|
| 64 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 65 |
+ *iRead = fread( pBuf, 1, iSize, data->hFile ); |
|
| 66 |
+ return MNG_TRUE; |
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+// write data to the open file |
|
| 70 |
+mng_bool BlMng_writedata( mng_handle hMNG, mng_ptr pBuf, mng_uint32 iSize, mng_uint32 * iWritten ) |
|
| 71 |
+{
|
|
| 72 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 73 |
+ *iWritten = fwrite( pBuf, 1, iSize, data->hFile ); |
|
| 74 |
+ return MNG_TRUE; |
|
| 75 |
+} |
|
| 76 |
+ |
|
| 77 |
+// MNG library has processed the header information |
|
| 78 |
+mng_bool BlMng_processheader( mng_handle hMNG, mng_uint32 iWidth, mng_uint32 iHeight ) |
|
| 79 |
+{
|
|
| 80 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 81 |
+ |
|
| 82 |
+ // free old canvas (in case there is already one) |
|
| 83 |
+ if( data->canvas != NULL ) {
|
|
| 84 |
+ free( data->canvas ); |
|
| 85 |
+ data->canvas = NULL; |
|
| 86 |
+ printf( "</blm>\n" ); |
|
| 87 |
+ } |
|
| 88 |
+ |
|
| 89 |
+ // free old movie |
|
| 90 |
+ if( data->movie ) {
|
|
| 91 |
+ BlinkenMovieFree( data->movie ); |
|
| 92 |
+ data->movie = NULL; |
|
| 93 |
+ } |
|
| 94 |
+ |
|
| 95 |
+ // remember dimensions and allocate new canvas |
|
| 96 |
+ data->width = iWidth; |
|
| 97 |
+ data->height = iHeight; |
|
| 98 |
+ data->canvas = (unsigned char *)malloc( iHeight * iWidth * 3 ); |
|
| 99 |
+ if( data->canvas == NULL ) |
|
| 100 |
+ return MNG_FALSE; |
|
| 101 |
+ data->counter_msec = 0; |
|
| 102 |
+ data->timer_msec = 0; |
|
| 103 |
+ |
|
| 104 |
+ // create new empty movie |
|
| 105 |
+ data->movie = BlinkenMovieNew( iHeight, iWidth, 3, 255 ); // always 24 bit RGB |
|
| 106 |
+ if( data->movie == NULL ) |
|
| 107 |
+ return MNG_FALSE; |
|
| 108 |
+ |
|
| 109 |
+ return MNG_TRUE; |
|
| 110 |
+} |
|
| 111 |
+ |
|
| 112 |
+// get access to a line of the canvas |
|
| 113 |
+mng_ptr BlMng_getcanvasline( mng_handle hMNG, mng_uint32 iLinenr ) |
|
| 114 |
+{
|
|
| 115 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 116 |
+ |
|
| 117 |
+ // return pointer to line |
|
| 118 |
+ if( iLinenr < data->height ) |
|
| 119 |
+ return (mng_ptr)(data->canvas + iLinenr * data->width * 3); |
|
| 120 |
+ else |
|
| 121 |
+ return (mng_ptr)NULL; |
|
| 122 |
+} |
|
| 123 |
+ |
|
| 124 |
+// the MNG library thinks that (a part of) the canvas should be shown |
|
| 125 |
+mng_bool BlMng_refresh( mng_handle __attribute__(( unused )) hMNG, mng_uint32 __attribute__(( unused )) iX, mng_uint32 __attribute__(( unused )) iY, mng_uint32 __attribute__(( unused )) iWidth, mng_uint32 __attribute__(( unused )) iHeight ) |
|
| 126 |
+{
|
|
| 127 |
+ // nothing to do here for BlinkenLib as we are only converting and not displaying |
|
| 128 |
+ return MNG_TRUE; |
|
| 129 |
+} |
|
| 130 |
+ |
|
| 131 |
+// the MNG library want to know how many milliseconds have passed |
|
| 132 |
+mng_uint32 BlMng_gettickcount( mng_handle hMNG ) |
|
| 133 |
+{
|
|
| 134 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 135 |
+ |
|
| 136 |
+ // just return the current number of milliseconds (only converting, do not use real time for this) |
|
| 137 |
+ return data->counter_msec; |
|
| 138 |
+} |
|
| 139 |
+ |
|
| 140 |
+// the MNG library wants to be be called again after some milliseconds |
|
| 141 |
+mng_bool BlMng_settimer( mng_handle hMNG, mng_uint32 iMsecs ) |
|
| 142 |
+{
|
|
| 143 |
+ BlMng_userdata * data = (BlMng_userdata *)mng_get_userdata( hMNG ); |
|
| 144 |
+ |
|
| 145 |
+ // just remember the number of milliseconds |
|
| 146 |
+ data->timer_msec = iMsecs; |
|
| 147 |
+ |
|
| 148 |
+ return MNG_TRUE; |
|
| 149 |
+} |
|
| 150 |
+ |
|
| 151 |
+// save as new frame to current movie |
|
| 152 |
+void BlMng_save_frame( stBlinkenMovie * movie, unsigned int msec, unsigned int width, unsigned int height, unsigned char * data ) |
|
| 153 |
+{
|
|
| 154 |
+ stBlinkenFrame * frame; |
|
| 155 |
+ unsigned int c, x, y; |
|
| 156 |
+ |
|
| 157 |
+ // check that a movie is present |
|
| 158 |
+ if( movie == NULL ) |
|
| 159 |
+ return; |
|
| 160 |
+ |
|
| 161 |
+ // create new frame (24 bit RGB) |
|
| 162 |
+ frame = BlinkenFrameNew( height, width, 3, 255, msec ); |
|
| 163 |
+ if( frame == NULL ) |
|
| 164 |
+ return; |
|
| 165 |
+ |
|
| 166 |
+ // set pixels of frame |
|
| 167 |
+ for( y = 0; y < height; y++ ) {
|
|
| 168 |
+ for( x = 0; x < width; x++ ) {
|
|
| 169 |
+ for( c = 0; c < 3; c++ ) {
|
|
| 170 |
+ BlinkenFrameSetPixel( frame, y, x, c, *data ); |
|
| 171 |
+ data++; |
|
| 172 |
+ } |
|
| 173 |
+ } |
|
| 174 |
+ } |
|
| 175 |
+ |
|
| 176 |
+ // append frame to movie |
|
| 177 |
+ if( BlinkenMovieAppendFrame( movie, frame ) != 0 ) |
|
| 178 |
+ BlinkenFrameFree( frame ); |
|
| 179 |
+} |
|
| 180 |
+ |
|
| 181 |
+// compress pixel data in a frame |
|
| 182 |
+void BlMng_compress_frame( stBlinkenFrame * frame, unsigned char * * p_out_ptr, unsigned int * p_out_len ) |
|
| 183 |
+{
|
|
| 184 |
+ unsigned int width = BlinkenFrameGetWidth( frame ); |
|
| 185 |
+ unsigned int height = BlinkenFrameGetHeight( frame ); |
|
| 186 |
+ // channels is always 3, maxval is always 255 - this function is only called with frames from moivies with those parameters |
|
| 187 |
+ unsigned int row_stride, raw_len, y, x, c; |
|
| 188 |
+ unsigned char * raw_ptr, * ptr, * out_ptr; |
|
| 189 |
+ unsigned long out_len; |
|
| 190 |
+ |
|
| 191 |
+ // assemble raw data to compress |
|
| 192 |
+ row_stride = width * 3 + 1; // rows are preceeded by filter ID |
|
| 193 |
+ raw_len = row_stride * height; |
|
| 194 |
+ raw_ptr = (unsigned char *)malloc( raw_len ); |
|
| 195 |
+ ptr = raw_ptr; |
|
| 196 |
+ for( y = 0; y < height; y++ ) {
|
|
| 197 |
+ // filter ID |
|
| 198 |
+ *ptr = MNG_FILTER_NONE; // no filtering |
|
| 199 |
+ ptr++; |
|
| 200 |
+ // pixel data of row |
|
| 201 |
+ for( x = 0; x < width; x++ ) {
|
|
| 202 |
+ for( c = 0; c < 3; c++ ) {
|
|
| 203 |
+ *ptr = BlinkenFrameGetPixel( frame, y, x, c ); |
|
| 204 |
+ ptr++; |
|
| 205 |
+ } |
|
| 206 |
+ } |
|
| 207 |
+ } // for( y ... |
|
| 208 |
+ |
|
| 209 |
+ // compress data |
|
| 210 |
+ out_len = raw_len + (raw_len + 999) / 1000 + 12; // must be at least <source length> * 1.001 + 12 |
|
| 211 |
+ out_ptr = (unsigned char *)malloc( out_len ); |
|
| 212 |
+ compress2( out_ptr, &out_len, raw_ptr, raw_len, Z_BEST_COMPRESSION ); |
|
| 213 |
+ free( raw_ptr ); |
|
| 214 |
+ |
|
| 215 |
+ // return allocated compressed data |
|
| 216 |
+ *p_out_ptr = out_ptr; |
|
| 217 |
+ *p_out_len = (unsigned int)out_len; |
|
| 218 |
+} |
|
| 219 |
+ |
|
| 220 |
+ |
|
| 221 |
+ |
|
| 222 |
+// load a MNG file as BlinkenMovie |
|
| 223 |
+stBlinkenMovie * BlinkenMngLoad( char * pFilename ) |
|
| 224 |
+{
|
|
| 225 |
+ BlMng_userdata * data; |
|
| 226 |
+ mng_handle hMNG; |
|
| 227 |
+ stBlinkenMovie * movie = NULL; |
|
| 228 |
+ |
|
| 229 |
+ if( pFilename == NULL ) |
|
| 230 |
+ return NULL; |
|
| 231 |
+ |
|
| 232 |
+ // create new structure for state of operation |
|
| 233 |
+ data = (BlMng_userdata *)malloc( sizeof( BlMng_userdata ) ); |
|
| 234 |
+ if( data != NULL ) {
|
|
| 235 |
+ data->hFile = NULL; |
|
| 236 |
+ data->width = 0; |
|
| 237 |
+ data->height = 0; |
|
| 238 |
+ data->canvas = NULL; |
|
| 239 |
+ data->movie = NULL; |
|
| 240 |
+ |
|
| 241 |
+ // open MNG file for reading |
|
| 242 |
+ data->hFile = fopen( pFilename, "rb" ); |
|
| 243 |
+ if( data->hFile != NULL ) {
|
|
| 244 |
+ |
|
| 245 |
+ // initialize MNG library |
|
| 246 |
+ hMNG = mng_initialize( (mng_ptr)data, BlMng_alloc, BlMng_free, MNG_NULL ); |
|
| 247 |
+ if( hMNG ) {
|
|
| 248 |
+ |
|
| 249 |
+ // set MNG callbacks |
|
| 250 |
+ if( mng_setcb_openstream( hMNG, BlMng_openstream ) == 0 && |
|
| 251 |
+ mng_setcb_closestream( hMNG, BlMng_closestream ) == 0 && |
|
| 252 |
+ mng_setcb_readdata( hMNG, BlMng_readdata ) == 0 && |
|
| 253 |
+ mng_setcb_processheader( hMNG, BlMng_processheader ) == 0 && |
|
| 254 |
+ mng_setcb_getcanvasline( hMNG, BlMng_getcanvasline ) == 0 && |
|
| 255 |
+ mng_setcb_refresh( hMNG, BlMng_refresh ) == 0 && |
|
| 256 |
+ mng_setcb_gettickcount( hMNG, BlMng_gettickcount ) == 0 && |
|
| 257 |
+ mng_setcb_settimer( hMNG, BlMng_settimer ) == 0 && |
|
| 258 |
+ mng_set_canvasstyle( hMNG, MNG_CANVAS_RGB8 ) == 0 ) {
|
|
| 259 |
+ |
|
| 260 |
+ // read MNG file to memory |
|
| 261 |
+ if( mng_read( hMNG ) == 0 ) {
|
|
| 262 |
+ |
|
| 263 |
+ // start "displaying" |
|
| 264 |
+ mng_retcode iRC = mng_display( hMNG ); |
|
| 265 |
+ if( iRC == 0 || iRC == MNG_NEEDTIMERWAIT ) {
|
|
| 266 |
+ |
|
| 267 |
+ // "display" loop |
|
| 268 |
+ int b_saved = 0; |
|
| 269 |
+ while( iRC == MNG_NEEDTIMERWAIT && data->timer_msec > 0 ) {
|
|
| 270 |
+ |
|
| 271 |
+ // save fame to movie |
|
| 272 |
+ BlMng_save_frame( data->movie, data->timer_msec, data->width, data->height, data->canvas ); |
|
| 273 |
+ b_saved = 1; |
|
| 274 |
+ |
|
| 275 |
+ // let requeired time elapse for MNG library |
|
| 276 |
+ data->counter_msec += data->timer_msec; |
|
| 277 |
+ data->timer_msec = 0; |
|
| 278 |
+ |
|
| 279 |
+ // "display" next frame |
|
| 280 |
+ iRC = mng_display_resume( hMNG ); |
|
| 281 |
+ if( iRC != 0 && iRC != MNG_NEEDTIMERWAIT ) |
|
| 282 |
+ break; |
|
| 283 |
+ |
|
| 284 |
+ } // while( iRC == MNG_NEEDTIMERWAIT && data->timer_msec > 0 ) |
|
| 285 |
+ |
|
| 286 |
+ // save single frame if no frame saved yet (i.e. not an animated MNG image) |
|
| 287 |
+ if( ! b_saved ) |
|
| 288 |
+ BlMng_save_frame( data->movie, data->timer_msec, data->width, data->height, data->canvas ); |
|
| 289 |
+ |
|
| 290 |
+ // if movie has more than one frame and the last frame is empty with duration of 1ms, remove last frame |
|
| 291 |
+ // - a black frame with 1ms duration is inserted by MNG library when MNG requests to clean canvas after displaying |
|
| 292 |
+ // - the reqauest to clear canvas after end of MNG anmation is needed to preserve duration of last frame (when converting from native format to MNG) |
|
| 293 |
+ // - remove this frame that is created by the described side effect |
|
| 294 |
+ {
|
|
| 295 |
+ unsigned int frame_cnt = BlinkenMovieGetFrameCnt( data->movie ); |
|
| 296 |
+ if( frame_cnt >= 1 ) {
|
|
| 297 |
+ stBlinkenFrame * frame = BlinkenMovieGetFrame( data->movie, frame_cnt - 1 ); |
|
| 298 |
+ if( frame != NULL && BlinkenFrameIsEmpty( frame ) ) |
|
| 299 |
+ BlinkenMovieDeleteFrame( data->movie, frame_cnt - 1 ); |
|
| 300 |
+ } |
|
| 301 |
+ } |
|
| 302 |
+ |
|
| 303 |
+ // stop "displaying" |
|
| 304 |
+ mng_display_freeze( hMNG ); |
|
| 305 |
+ |
|
| 306 |
+ } // if( iRC == 0 || iRC == MNG_NEEDTIMERWAIT ) |
|
| 307 |
+ |
|
| 308 |
+ } // if( mng_read( ... ) == 0 ) |
|
| 309 |
+ |
|
| 310 |
+ } // if( mng_setcb_... ) |
|
| 311 |
+ |
|
| 312 |
+ // shutdown MNG library |
|
| 313 |
+ mng_cleanup( &hMNG ); |
|
| 314 |
+ |
|
| 315 |
+ } // if( hMNG ) |
|
| 316 |
+ |
|
| 317 |
+ // close file |
|
| 318 |
+ fclose( data->hFile ); |
|
| 319 |
+ |
|
| 320 |
+ } // if( data->hFile != NULL ) |
|
| 321 |
+ |
|
| 322 |
+ // fetch created movie from state |
|
| 323 |
+ movie = data->movie; |
|
| 324 |
+ data->movie = NULL; |
|
| 325 |
+ |
|
| 326 |
+ // free data structure for state |
|
| 327 |
+ if( data->canvas != NULL ) |
|
| 328 |
+ free( data->canvas ); |
|
| 329 |
+ free( data ); |
|
| 330 |
+ |
|
| 331 |
+ } // if( data != NULL ) |
|
| 332 |
+ |
|
| 333 |
+ return movie; |
|
| 334 |
+} |
|
| 335 |
+ |
|
| 336 |
+int BlinkenMngSave( stBlinkenMovie * pMovie, char * pFilename ) |
|
| 337 |
+{
|
|
| 338 |
+ BlMng_userdata * data; |
|
| 339 |
+ mng_handle hMNG; |
|
| 340 |
+ int b_success = 0; |
|
| 341 |
+ |
|
| 342 |
+ if( pMovie == NULL || pFilename == NULL ) |
|
| 343 |
+ return -1; |
|
| 344 |
+ |
|
| 345 |
+ // create new structure for state of operation |
|
| 346 |
+ data = (BlMng_userdata *)malloc( sizeof( BlMng_userdata ) ); |
|
| 347 |
+ if( data != NULL ) {
|
|
| 348 |
+ data->hFile = NULL; |
|
| 349 |
+ data->width = BlinkenMovieGetWidth( pMovie ); |
|
| 350 |
+ data->height = BlinkenMovieGetHeight( pMovie ); |
|
| 351 |
+ data->canvas = NULL; |
|
| 352 |
+ data->movie = NULL; |
|
| 353 |
+ |
|
| 354 |
+ // convert movie to suitable format |
|
| 355 |
+ data->movie = BlinkenMovieClone( pMovie ); |
|
| 356 |
+ if( data->movie != NULL ) {
|
|
| 357 |
+ BlinkenMovieResize( data->movie, data->height, data->width, 3, 255 ); |
|
| 358 |
+ |
|
| 359 |
+ // open MNG file for writing |
|
| 360 |
+ data->hFile = fopen( pFilename, "wb" ); |
|
| 361 |
+ if( data->hFile != NULL ) {
|
|
| 362 |
+ |
|
| 363 |
+ // initialize MNG library |
|
| 364 |
+ hMNG = mng_initialize( (mng_ptr)data, BlMng_alloc, BlMng_free, MNG_NULL ); |
|
| 365 |
+ if( hMNG ) {
|
|
| 366 |
+ |
|
| 367 |
+ // set MNG callbacks |
|
| 368 |
+ if( mng_setcb_openstream( hMNG, BlMng_openstream ) == 0 && |
|
| 369 |
+ mng_setcb_closestream( hMNG, BlMng_closestream ) == 0 && |
|
| 370 |
+ mng_setcb_writedata( hMNG, BlMng_writedata ) == 0 ) {
|
|
| 371 |
+ |
|
| 372 |
+ // create new MNG image in memory |
|
| 373 |
+ if( mng_create( hMNG ) == 0 ) {
|
|
| 374 |
+ |
|
| 375 |
+ // write MNG chunks |
|
| 376 |
+ do {
|
|
| 377 |
+ unsigned int frame_cnt = BlinkenMovieGetFrameCnt( data->movie ); |
|
| 378 |
+ unsigned int total_duration = BlinkenMovieGetDuration( data->movie ); |
|
| 379 |
+ unsigned int frame_no; |
|
| 380 |
+ |
|
| 381 |
+ // write MG header chunks |
|
| 382 |
+ if( mng_putchunk_mhdr( hMNG, |
|
| 383 |
+ data->width, data->height, // dimensions |
|
| 384 |
+ 1000, 0, frame_cnt, total_duration, // ticks per second, layer, frame count, duration |
|
| 385 |
+ MNG_SIMPLICITY_VALID | MNG_SIMPLICITY_SIMPLEFEATURES | MNG_SIMPLICITY_COMPLEXFEATURES // simplicity |
|
| 386 |
+ ) != 0 ) |
|
| 387 |
+ break; |
|
| 388 |
+ |
|
| 389 |
+ if( mng_putchunk_save( hMNG, |
|
| 390 |
+ MNG_TRUE, // empty SAVE chunk |
|
| 391 |
+ 0, 0 // no offset, no count |
|
| 392 |
+ ) != 0 ) |
|
| 393 |
+ break; |
|
| 394 |
+ |
|
| 395 |
+ // tell MNG player to clear canvas after end of MNG animation |
|
| 396 |
+ // - this is needed to preserve duration of last frame |
|
| 397 |
+ // - this results in a black frame with 1ms duration at the end of the MNG as side effect |
|
| 398 |
+ if( mng_putchunk_term( hMNG, |
|
| 399 |
+ MNG_TERMACTION_CLEAR, MNG_ITERACTION_CLEAR, // show last frame forever after end of animation |
|
| 400 |
+ 0, 0 // no repeat delay, no maximum iteration count |
|
| 401 |
+ ) != 0 ) |
|
| 402 |
+ break; |
|
| 403 |
+ |
|
| 404 |
+ // write frames |
|
| 405 |
+ for( frame_no = 0; frame_no < frame_cnt; frame_no++ ) {
|
|
| 406 |
+ |
|
| 407 |
+ // get current frame |
|
| 408 |
+ stBlinkenFrame * frame = BlinkenMovieGetFrame( data->movie, frame_no ); |
|
| 409 |
+ unsigned int frame_duration = BlinkenFrameGetDuration( frame ); |
|
| 410 |
+ |
|
| 411 |
+ // write MNG frame header chunks |
|
| 412 |
+ if( mng_putchunk_seek( hMNG, |
|
| 413 |
+ 0, MNG_NULL // no name |
|
| 414 |
+ ) != 0 ) |
|
| 415 |
+ break; |
|
| 416 |
+ |
|
| 417 |
+ if( mng_putchunk_fram( hMNG, |
|
| 418 |
+ MNG_FALSE, frame_no == 0 ? MNG_FRAMINGMODE_1 : MNG_FRAMINGMODE_NOCHANGE, // empty, mode |
|
| 419 |
+ 0, MNG_NULL, // frame name |
|
| 420 |
+ MNG_CHANGEDELAY_DEFAULT, MNG_CHANGETIMOUT_NO, MNG_CHANGECLIPPING_NO, MNG_CHANGESYNCID_NO, // changing only delay |
|
| 421 |
+ frame_duration, 0, // new delay, no new timeout |
|
| 422 |
+ 0, 0, 0, 0, 0, // no new boundary |
|
| 423 |
+ 0, 0 // no count, no IDs |
|
| 424 |
+ ) != 0 ) |
|
| 425 |
+ break; |
|
| 426 |
+ |
|
| 427 |
+ if( mng_putchunk_defi( hMNG, |
|
| 428 |
+ 0, MNG_DONOTSHOW_VISIBLE, MNG_ABSTRACT, // no ID, visible, abstract |
|
| 429 |
+ MNG_TRUE, 0, 0, // top left location |
|
| 430 |
+ MNG_FALSE, 0, 0, 0, 0 // no clipping |
|
| 431 |
+ ) != 0 ) |
|
| 432 |
+ break; |
|
| 433 |
+ |
|
| 434 |
+ if( mng_putchunk_ihdr( hMNG, |
|
| 435 |
+ data->width, data->height, 8, MNG_COLORTYPE_RGB, // dimensions and 8 bit RGB |
|
| 436 |
+ MNG_COMPRESSION_DEFLATE, MNG_FILTER_ADAPTIVE, MNG_INTERLACE_NONE // deflate compression, adaptive filter, no interlacing |
|
| 437 |
+ ) != 0 ) |
|
| 438 |
+ break; |
|
| 439 |
+ |
|
| 440 |
+ // write MNG frame data |
|
| 441 |
+ {
|
|
| 442 |
+ unsigned char * ptr; |
|
| 443 |
+ unsigned int len; |
|
| 444 |
+ mng_retcode iRC; |
|
| 445 |
+ |
|
| 446 |
+ BlMng_compress_frame( frame, &ptr, &len ); |
|
| 447 |
+ |
|
| 448 |
+ iRC = mng_putchunk_idat( hMNG, (mng_uint32)len, (mng_ptr)ptr ); |
|
| 449 |
+ free( ptr ); |
|
| 450 |
+ if( iRC != 0 ) |
|
| 451 |
+ break; |
|
| 452 |
+ } |
|
| 453 |
+ |
|
| 454 |
+ // write MNG frame footer |
|
| 455 |
+ if( mng_putchunk_iend( hMNG ) != 0 ) |
|
| 456 |
+ break; |
|
| 457 |
+ |
|
| 458 |
+ } // for( frame ... |
|
| 459 |
+ if( frame_no < frame_cnt ) // if not all frames have been processed there was en error |
|
| 460 |
+ break; |
|
| 461 |
+ |
|
| 462 |
+ // output MNG end chunk |
|
| 463 |
+ if( mng_putchunk_mend( hMNG ) != 0 ) |
|
| 464 |
+ break; |
|
| 465 |
+ |
|
| 466 |
+ // write MNG chuks to file |
|
| 467 |
+ if( mng_write( hMNG ) != 0 ) |
|
| 468 |
+ break; |
|
| 469 |
+ |
|
| 470 |
+ b_success = 1; |
|
| 471 |
+ |
|
| 472 |
+ } while( 0 ); |
|
| 473 |
+ |
|
| 474 |
+ } // if( mng_create( hMNG ) == 0 ) |
|
| 475 |
+ |
|
| 476 |
+ } // if( mng_setcb_... ) |
|
| 477 |
+ |
|
| 478 |
+ // shutdown MNG library |
|
| 479 |
+ mng_cleanup( &hMNG ); |
|
| 480 |
+ |
|
| 481 |
+ } // if( hMNG ) |
|
| 482 |
+ |
|
| 483 |
+ // close file |
|
| 484 |
+ fclose( data->hFile ); |
|
| 485 |
+ |
|
| 486 |
+ } // if( data->hFile != NULL ) |
|
| 487 |
+ |
|
| 488 |
+ // free movie |
|
| 489 |
+ BlinkenMovieFree( data->movie ); |
|
| 490 |
+ |
|
| 491 |
+ } // if( data->movie != NULL ) |
|
| 492 |
+ |
|
| 493 |
+ // free data structure for state |
|
| 494 |
+ if( data->canvas != NULL ) |
|
| 495 |
+ free( data->canvas ); |
|
| 496 |
+ free( data ); |
|
| 497 |
+ |
|
| 498 |
+ } // if( data != NULL ) |
|
| 499 |
+ |
|
| 500 |
+ return b_success ? 0 : -1; |
|
| 501 |
+} |
|
| 502 |
+ |
| ... | ... |
@@ -0,0 +1,24 @@ |
| 1 |
+/* BlinkenLib |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 |
+ * Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
|
| 4 |
+ * Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
| 5 |
+ * a blinkenarea.org project |
|
| 6 |
+ */ |
|
| 7 |
+ |
|
| 8 |
+#ifndef INC_BlinkenLib_BlinkenMng |
|
| 9 |
+#define INC_BlinkenLib_BlinkenMng |
|
| 10 |
+ |
|
| 11 |
+#include <BlinkenLib/config.h> |
|
| 12 |
+#include <BlinkenLib/BlinkenFrame.h> |
|
| 13 |
+#include <BlinkenLib/BlinkenMovie.h> |
|
| 14 |
+ |
|
| 15 |
+#ifndef BLINKENLIB_CFG_MNG |
|
| 16 |
+#error This file is to be used for MNG support only. |
|
| 17 |
+#endif // #ifndef BLINKENLIB_CFG_MNG |
|
| 18 |
+ |
|
| 19 |
+stBlinkenMovie * BlinkenMngLoad( char * pFilename ); |
|
| 20 |
+ |
|
| 21 |
+int BlinkenMngSave( stBlinkenMovie * pMovie, char * pFilename ); |
|
| 22 |
+ |
|
| 23 |
+#endif //#ifndef INC_BlinkenLib_BlinkenMng |
|
| 24 |
+ |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -23,6 +23,9 @@ |
| 23 | 23 |
#include <BlinkenLib/BlinkenFrame.h> |
| 24 | 24 |
#include <BlinkenLib/BlinkenMovie.h> |
| 25 | 25 |
#include <BlinkenLib/Tools.h> |
| 26 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 27 |
+#include <BlinkenLib/BlinkenMng.h> |
|
| 28 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 26 | 29 |
|
| 27 | 30 |
struct sBlinkenMovie |
| 28 | 31 |
{
|
| ... | ... |
@@ -1115,6 +1118,15 @@ stBlinkenMovie * BlinkenMovieLoadBbm( char * pFilename ) |
| 1115 | 1118 |
return pMovie; |
| 1116 | 1119 |
} |
| 1117 | 1120 |
|
| 1121 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 1122 |
+ |
|
| 1123 |
+stBlinkenMovie * BlinkenMovieLoadMng( char * pFilename ) |
|
| 1124 |
+{
|
|
| 1125 |
+ return BlinkenMngLoad( pFilename ); |
|
| 1126 |
+} |
|
| 1127 |
+ |
|
| 1128 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 1129 |
+ |
|
| 1118 | 1130 |
stBlinkenMovie * BlinkenMovieLoad( char * pFilename ) |
| 1119 | 1131 |
{
|
| 1120 | 1132 |
int len; |
| ... | ... |
@@ -1131,6 +1143,10 @@ stBlinkenMovie * BlinkenMovieLoad( char * pFilename ) |
| 1131 | 1143 |
return BlinkenMovieLoadBml( pFilename ); |
| 1132 | 1144 |
if( len > 4 && strcmp( pFilename + len - 4, ".bbm" ) == 0 ) |
| 1133 | 1145 |
return BlinkenMovieLoadBbm( pFilename ); |
| 1146 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 1147 |
+ if( len > 4 && strcmp( pFilename + len - 4, ".mng" ) == 0 ) |
|
| 1148 |
+ return BlinkenMovieLoadMng( pFilename ); |
|
| 1149 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 1134 | 1150 |
return NULL; |
| 1135 | 1151 |
} |
| 1136 | 1152 |
|
| ... | ... |
@@ -1443,6 +1459,15 @@ int BlinkenMovieSaveBbm( stBlinkenMovie * pMovie, char * pFilename ) |
| 1443 | 1459 |
return 0; |
| 1444 | 1460 |
} |
| 1445 | 1461 |
|
| 1462 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 1463 |
+ |
|
| 1464 |
+int BlinkenMovieSaveMng( stBlinkenMovie * pMovie, char * pFilename ) |
|
| 1465 |
+{
|
|
| 1466 |
+ return BlinkenMngSave( pMovie, pFilename ); |
|
| 1467 |
+} |
|
| 1468 |
+ |
|
| 1469 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 1470 |
+ |
|
| 1446 | 1471 |
int BlinkenMovieSave( stBlinkenMovie * pMovie, char * pFilename ) |
| 1447 | 1472 |
{
|
| 1448 | 1473 |
int len; |
| ... | ... |
@@ -1459,6 +1484,10 @@ int BlinkenMovieSave( stBlinkenMovie * pMovie, char * pFilename ) |
| 1459 | 1484 |
return BlinkenMovieSaveBml( pMovie, pFilename ); |
| 1460 | 1485 |
if( len > 4 && strcmp( pFilename + len - 4, ".bbm" ) == 0 ) |
| 1461 | 1486 |
return BlinkenMovieSaveBbm( pMovie, pFilename ); |
| 1487 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 1488 |
+ if( len > 4 && strcmp( pFilename + len - 4, ".mng" ) == 0 ) |
|
| 1489 |
+ return BlinkenMovieSaveMng( pMovie, pFilename ); |
|
| 1490 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 1462 | 1491 |
return -1; |
| 1463 | 1492 |
} |
| 1464 | 1493 |
|
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -8,6 +8,7 @@ |
| 8 | 8 |
#ifndef INC_BlinkenLib_BlinkenMovie |
| 9 | 9 |
#define INC_BlinkenLib_BlinkenMovie |
| 10 | 10 |
|
| 11 |
+#include <BlinkenLib/config.h> |
|
| 11 | 12 |
#include <BlinkenLib/BlinkenFrame.h> |
| 12 | 13 |
|
| 13 | 14 |
#ifdef WIN32 |
| ... | ... |
@@ -58,12 +59,18 @@ stBlinkenMovie * BlinkenMovieLoadBlm( char * pFilename ); |
| 58 | 59 |
stBlinkenMovie * BlinkenMovieLoadBmm( char * pFilename ); |
| 59 | 60 |
stBlinkenMovie * BlinkenMovieLoadBml( char * pFilename ); |
| 60 | 61 |
stBlinkenMovie * BlinkenMovieLoadBbm( char * pFilename ); |
| 62 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 63 |
+stBlinkenMovie * BlinkenMovieLoadMng( char * pFilename ); |
|
| 64 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 61 | 65 |
stBlinkenMovie * BlinkenMovieLoad( char * pFilename ); |
| 62 | 66 |
|
| 63 | 67 |
int BlinkenMovieSaveBlm( stBlinkenMovie * pMovie, char * pFilename ); |
| 64 | 68 |
int BlinkenMovieSaveBmm( stBlinkenMovie * pMovie, char * pFilename ); |
| 65 | 69 |
int BlinkenMovieSaveBml( stBlinkenMovie * pMovie, char * pFilename ); |
| 66 | 70 |
int BlinkenMovieSaveBbm( stBlinkenMovie * pMovie, char * pFilename ); |
| 71 |
+#ifdef BLINKENLIB_CFG_MNG |
|
| 72 |
+int BlinkenMovieSaveMng( stBlinkenMovie * pMovie, char * pFilename ); |
|
| 73 |
+#endif // #ifdef BLINKENLIB_CFG_MNG |
|
| 67 | 74 |
int BlinkenMovieSave( stBlinkenMovie * pMovie, char * pFilename ); |
| 68 | 75 |
|
| 69 | 76 |
void BlinkenMovieSend( stBlinkenMovie * pMovie, SOCKET udpSocket, etBlinkenProto proto, int maxidle ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -409,7 +409,8 @@ int main( int argCnt, char * * args ) |
| 409 | 409 |
|
| 410 | 410 |
//print info |
| 411 | 411 |
printf( "BlinkenLib - BlinkenOutput\n" |
| 412 |
- "version 0.5.5 date 2008-03-29\n" |
|
| 412 |
+ "version 0.6.0 date 2008-05-15\n" |
|
| 413 |
+ "config "BLINKENLIB_CONFIG"\n" |
|
| 413 | 414 |
"Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org>\n" |
| 414 | 415 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
| 415 | 416 |
"a blinkenarea.org project\n\n" ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -350,7 +350,7 @@ int main( int argCnt, char * * args ) |
| 350 | 350 |
|
| 351 | 351 |
//print info |
| 352 | 352 |
printf( "BlinkenLib - BlinkenOutput\n" |
| 353 |
- "version 0.5.5 date 2008-03-29\n" |
|
| 353 |
+ "version 0.6.0 date 2008-05-15" |
|
| 354 | 354 |
"Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org>\n" |
| 355 | 355 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
| 356 | 356 |
"a blinkenarea.org project\n\n" ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -32,7 +32,8 @@ int main( int argCnt, char * * args ) |
| 32 | 32 |
|
| 33 | 33 |
//print info |
| 34 | 34 |
printf( "BlinkenLib - BlinkenRecv\n" |
| 35 |
- "version 0.5.5 date 2008-03-29\n" |
|
| 35 |
+ "version 0.6.0 date 2008-05-15\n" |
|
| 36 |
+ "config "BLINKENLIB_CONFIG"\n" |
|
| 36 | 37 |
"Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org>\n" |
| 37 | 38 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
| 38 | 39 |
"a blinkenarea.org project\n\n" ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
/* BlinkenLib |
| 2 |
- * version 0.5.5 date 2008-03-29 |
|
| 2 |
+ * version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
* Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
* Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
* a blinkenarea.org project |
| ... | ... |
@@ -35,7 +35,8 @@ int main( int argCnt, char * * args ) |
| 35 | 35 |
|
| 36 | 36 |
//print info |
| 37 | 37 |
printf( "BlinkenLib - BlinkenSend\n" |
| 38 |
- "version 0.5.5 date 2008-03-29\n" |
|
| 38 |
+ "version 0.6.0 date 2008-05-15\n" |
|
| 39 |
+ "config "BLINKENLIB_CONFIG"\n" |
|
| 39 | 40 |
"Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org>\n" |
| 40 | 41 |
"Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html\n" |
| 41 | 42 |
"a blinkenarea.org project\n\n" ); |
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
# BlinkenLib |
| 2 |
-# version 0.5.5 date 2008-03-29 |
|
| 2 |
+# version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
# Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
# a blinkenarea.org project |
| ... | ... |
@@ -11,23 +11,37 @@ AR=ar |
| 11 | 11 |
RANLIB=ranlib |
| 12 | 12 |
|
| 13 | 13 |
VERSION_MAJOR=0 |
| 14 |
-VERSION_MINOR=5 |
|
| 15 |
-VERSION_REVISION=5 |
|
| 14 |
+VERSION_MINOR=6 |
|
| 15 |
+VERSION_REVISION=0 |
|
| 16 | 16 |
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) |
| 17 | 17 |
|
| 18 |
-LIB_OBJS=BlinkenColorizer.o BlinkenFrame.o BlinkenMovie.o Tools.o |
|
| 18 |
+include ../config/config.mk |
|
| 19 |
+ |
|
| 20 |
+ifeq ($(BLINKENLIB_CFG_MNG),1) |
|
| 21 |
+BLINKEN_MNG_H=BlinkenMng.h |
|
| 22 |
+BLINKEN_MNG_O=BlinkenMng.o |
|
| 23 |
+LMNG=-lmng -lz |
|
| 24 |
+endif |
|
| 25 |
+ |
|
| 26 |
+LIB_OBJS=BlinkenColorizer.o BlinkenFrame.o BlinkenMovie.o $(BLINKEN_MNG_O) Tools.o |
|
| 19 | 27 |
|
| 20 | 28 |
.phony: all clean |
| 21 | 29 |
|
| 22 | 30 |
all: libBlinkenLib.a libBlinkenLib.so.$(VERSION_MAJOR) libBlinkenLib.so.$(VERSION) libBlinkenLib.so BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput |
| 23 | 31 |
|
| 32 |
+config.h: ../config/config.h |
|
| 33 |
+ cp $< $@ |
|
| 34 |
+ |
|
| 24 | 35 |
BlinkenColorizer.o: BlinkenColorizer.c BlinkenColorizer.h Tools.h |
| 25 | 36 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 26 | 37 |
|
| 27 |
-BlinkenFrame.o: BlinkenFrame.c BlinkenFrame.h BlinkenColorizer.h Tools.h |
|
| 38 |
+BlinkenFrame.o: BlinkenFrame.c BlinkenConstants.h BlinkenColorizer.h BlinkenFrame.h BlinkenColorizer.h Tools.h |
|
| 39 |
+ $(CC) $(CFLAGS) -c -o $@ $< |
|
| 40 |
+ |
|
| 41 |
+BlinkenMovie.o: BlinkenMovie.c BlinkenConstants.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h $(BLINKEN_MNG_H) Tools.h config.h |
|
| 28 | 42 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 29 | 43 |
|
| 30 |
-BlinkenMovie.o: BlinkenMovie.c BlinkenFrame.h BlinkenMovie.h Tools.h |
|
| 44 |
+BlinkenMng.o: BlinkenMng.c BlinkenConstants.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h Tools.h config.h |
|
| 31 | 45 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 32 | 46 |
|
| 33 | 47 |
Tools.o: Tools.c Tools.h |
| ... | ... |
@@ -38,38 +52,40 @@ libBlinkenLib.a: $(LIB_OBJS) |
| 38 | 52 |
$(RANLIB) $@ |
| 39 | 53 |
|
| 40 | 54 |
libBlinkenLib.so.$(VERSION): $(LIB_OBJS) |
| 41 |
- $(CC) -shared -Wl,-soname,libBlinkenLib.so.$(VERSION_MAJOR) -o $@ $+ |
|
| 55 |
+ $(CC) -shared -Wl,-soname,libBlinkenLib.so.$(VERSION_MAJOR) -o $@ $+ $(LMNG) |
|
| 42 | 56 |
|
| 43 | 57 |
libBlinkenLib.so.$(VERSION_MAJOR): libBlinkenLib.so.$(VERSION) |
| 58 |
+ rm -f $@ |
|
| 44 | 59 |
ln -s $< $@ |
| 45 | 60 |
|
| 46 | 61 |
libBlinkenLib.so: libBlinkenLib.so.$(VERSION_MAJOR) |
| 62 |
+ rm -f $@ |
|
| 47 | 63 |
ln -s $< $@ |
| 48 | 64 |
|
| 49 |
-BlinkenConv.o: BlinkenConv.c BlinkenLib.h |
|
| 65 |
+BlinkenConv.o: BlinkenConv.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h |
|
| 50 | 66 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 51 | 67 |
|
| 52 | 68 |
BlinkenConv: BlinkenConv.o libBlinkenLib.so |
| 53 | 69 |
$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib |
| 54 | 70 |
|
| 55 |
-BlinkenSend.o: BlinkenSend.c BlinkenLib.h |
|
| 71 |
+BlinkenSend.o: BlinkenSend.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h |
|
| 56 | 72 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 57 | 73 |
|
| 58 | 74 |
BlinkenSend: BlinkenSend.o libBlinkenLib.so |
| 59 | 75 |
$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib |
| 60 | 76 |
|
| 61 |
-BlinkenRecv.o: BlinkenRecv.c BlinkenLib.h |
|
| 77 |
+BlinkenRecv.o: BlinkenRecv.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h |
|
| 62 | 78 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 63 | 79 |
|
| 64 | 80 |
BlinkenRecv: BlinkenRecv.o libBlinkenLib.so |
| 65 | 81 |
$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib |
| 66 | 82 |
|
| 67 |
-BlinkenOutput.o: BlinkenOutput.c BlinkenLib.h |
|
| 83 |
+BlinkenOutput.o: BlinkenOutput.c BlinkenLib.h config.h BlinkenColorizer.h BlinkenFrame.h BlinkenMovie.h |
|
| 68 | 84 |
$(CC) $(CFLAGS) -c -o $@ $< |
| 69 | 85 |
|
| 70 | 86 |
BlinkenOutput: BlinkenOutput.o libBlinkenLib.so |
| 71 | 87 |
$(CC) $(LFLAGS) -o $@ $< -lBlinkenLib |
| 72 | 88 |
|
| 73 | 89 |
clean: |
| 74 |
- rm -f BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput libBlinkenLib.so libBlinkenLib.so.$(VERSION) libBlinkenLib.so.$(VERSION_MAJOR) libBlinkenLib.a *.o |
|
| 90 |
+ rm -f BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput libBlinkenLib.so libBlinkenLib.so.$(VERSION) libBlinkenLib.so.$(VERSION_MAJOR) libBlinkenLib.a *.o config.h |
|
| 75 | 91 |
|
| ... | ... |
@@ -1,5 +1,5 @@ |
| 1 | 1 |
# BlinkenLib |
| 2 |
-# version 0.5.5 date 2008-03-29 |
|
| 2 |
+# version 0.6.0 date 2008-05-15 |
|
| 3 | 3 |
# Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
| 4 | 4 |
# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
| 5 | 5 |
# a blinkenarea.org project |
| ... | ... |
@@ -7,8 +7,8 @@ |
| 7 | 7 |
INSTALL=install |
| 8 | 8 |
|
| 9 | 9 |
VERSION_MAJOR=0 |
| 10 |
-VERSION_MINOR=5 |
|
| 11 |
-VERSION_REVISION=5 |
|
| 10 |
+VERSION_MINOR=6 |
|
| 11 |
+VERSION_REVISION=0 |
|
| 12 | 12 |
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) |
| 13 | 13 |
|
| 14 | 14 |
ENV_PREFIX=$(shell echo $$PREFIX) |
| ... | ... |
@@ -25,19 +25,25 @@ else |
| 25 | 25 |
endif |
| 26 | 26 |
endif |
| 27 | 27 |
|
| 28 |
-HEADERS=BlinkenLib.h BlinkenMovie.h BlinkenFrame.h BlinkenColorizer.h |
|
| 28 |
+HEADERS=BlinkenLib.h BlinkenMovie.h BlinkenFrame.h BlinkenColorizer.h config.h |
|
| 29 | 29 |
LIBS=libBlinkenLib.a libBlinkenLib.so.$(VERSION) |
| 30 | 30 |
EXECS=BlinkenConv BlinkenSend BlinkenRecv BlinkenOutput |
| 31 | 31 |
|
| 32 |
-.phony: all clean install uninstall |
|
| 32 |
+.phony: all conf clean distclean install uninstall |
|
| 33 | 33 |
|
| 34 |
-all: |
|
| 34 |
+all: conf |
|
| 35 | 35 |
$(MAKE) -C BlinkenLib all |
| 36 | 36 |
|
| 37 |
-clean: |
|
| 37 |
+conf: |
|
| 38 |
+ $(MAKE) -C config all |
|
| 39 |
+ |
|
| 40 |
+clean: conf |
|
| 38 | 41 |
$(MAKE) -C BlinkenLib clean |
| 39 | 42 |
|
| 40 |
-install: |
|
| 43 |
+distclean: clean |
|
| 44 |
+ $(MAKE) -C config clean |
|
| 45 |
+ |
|
| 46 |
+install: all |
|
| 41 | 47 |
$(INSTALL) -d $(PREFIX)/include/BlinkenLib |
| 42 | 48 |
$(INSTALL) -t $(PREFIX)/include/BlinkenLib $(addprefix BlinkenLib/, $(HEADERS)) |
| 43 | 49 |
$(INSTALL) -d $(PREFIX)/lib |
| ... | ... |
@@ -0,0 +1,32 @@ |
| 1 |
+# BlinkenLib |
|
| 2 |
+# version 0.6.0 date 2008-05-15 |
|
| 3 |
+# Copyright 2004-2008 Stefan Schuermans <stefan@blinkenarea.org> |
|
| 4 |
+# Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
| 5 |
+# a blinkenarea.org project |
|
| 6 |
+ |
|
| 7 |
+CC=gcc |
|
| 8 |
+ |
|
| 9 |
+.phony: all clean |
|
| 10 |
+ |
|
| 11 |
+all: config.cfg config.mk config.h |
|
| 12 |
+ |
|
| 13 |
+mng.cfg: |
|
| 14 |
+ echo -n "MNG=" >mng.cfg |
|
| 15 |
+ (($(CC) -o mng mng.c -lmng && ./mng && echo "1") || echo "0") >>mng.cfg |
|
| 16 |
+ rm -f mng |
|
| 17 |
+ |
|
| 18 |
+config.cfg: mng.cfg |
|
| 19 |
+ cat $+ >config.cfg |
|
| 20 |
+ |
|
| 21 |
+config.mk: config.cfg |
|
| 22 |
+ sed 's/^\([A-Z]*\)=\([01]\)$$/BLINKENLIB_CFG_\1=\2/' <$< >$@ |
|
| 23 |
+ |
|
| 24 |
+config.h: config.cfg |
|
| 25 |
+ sed 's/^\([A-Z]*\)=0$$/#undef BLINKENLIB_CFG_\1/;s/^\([A-Z]*\)=1$$/#define BLINKENLIB_CFG_\1/' <$< >$@ |
|
| 26 |
+ echo -n '#define BLINKENLIB_CONFIG "' >>$@ |
|
| 27 |
+ sed 's/^\([A-Z]*\)=0$$/\1-/;s/^\([A-Z]*\)=1$$/\1+/' <$< | tr '\n' ' ' | sed 's/ *$$//' >>$@ |
|
| 28 |
+ echo '"' >>$@ |
|
| 29 |
+ |
|
| 30 |
+clean: |
|
| 31 |
+ rm -f *.cfg config.mk config.h |
|
| 32 |
+ |
| ... | ... |
@@ -0,0 +1,22 @@ |
| 1 |
+#include <libmng.h> |
|
| 2 |
+ |
|
| 3 |
+mng_ptr my_mng_alloc( mng_size_t iSize ) |
|
| 4 |
+{
|
|
| 5 |
+ void * ptr = malloc( iSize ); |
|
| 6 |
+ memset( ptr, 0, iSize ); |
|
| 7 |
+ return (mng_ptr)ptr; |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+void my_mng_free( mng_ptr pPtr, mng_size_t __attribute__(( unused )) iSize ) |
|
| 11 |
+{
|
|
| 12 |
+ free( pPtr ); |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 15 |
+int main( ) |
|
| 16 |
+{
|
|
| 17 |
+ mng_handle hMNG = mng_initialize( MNG_NULL, my_mng_alloc, my_mng_free, MNG_NULL ); |
|
| 18 |
+ mng_cleanup( &hMNG ); |
|
| 19 |
+ |
|
| 20 |
+ return 0; |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 0 | 23 |