/[projet1]/public/pc/shared_libraries/freeimage/v3.12.0/Examples/Generic/FIIO_Mem.h
Defence Force logotype

Contents of /public/pc/shared_libraries/freeimage/v3.12.0/Examples/Generic/FIIO_Mem.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 126 - (show annotations)
Mon Jul 13 12:20:10 2009 UTC (10 years, 10 months ago) by dbug
File MIME type: text/plain
File size: 2629 byte(s)
Added some shared libraries (UnitTest++, and FreeImage) to avoid having every single project brings its own libraries.
Ideally people should add them in a way we can upgrade versions without breaking things:
-> public/pc/shared_libraries/library_name/library_version/actuall_content
1 /*--------------------------------------------------------------------------*\
2 || fiio_mem.h by Ryan Rubley <ryan@lostreality.org> ||
3 || ||
4 || (v1.02) 4-28-2004 ||
5 || FreeImageIO to memory ||
6 || ||
7 \*--------------------------------------------------------------------------*/
8
9 #ifndef _FIIO_MEM_H_
10 #define _FIIO_MEM_H_
11
12 #include "freeimage.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 typedef struct fiio_mem_handle_s {
19 long filelen,datalen,curpos;
20 void *data;
21 } fiio_mem_handle;
22
23 /* it is up to the user to create a fiio_mem_handle and init datalen and data
24 * filelen will be pre-set to 0 by SaveToMem
25 * curpos will be pre-set to 0 by SaveToMem and LoadFromMem
26 * IMPORTANT: data should be set to NULL and datalen to 0,
27 * unless the user wants to manually malloc a larger buffer
28 */
29 FIBITMAP *FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags);
30 BOOL FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags);
31
32 void SetMemIO(FreeImageIO *io);
33 unsigned fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
34 unsigned fiio_mem_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle);
35 int fiio_mem_SeekProc(fi_handle handle, long offset, int origin);
36 long fiio_mem_TellProc(fi_handle handle);
37
38 /*** Example Usage ***
39
40 //variables
41 FIBITMAP *bitmap, *bitmap2;
42 fiio_mem_handle fmh;
43
44 //important initialization
45 fmh.data = NULL;
46 fmh.datalen = 0;
47
48 //load a regular file
49 bitmap = FreeImage_Load(FIF_PNG, "sample.png");
50
51 //save the file to memory
52 FreeImage_SaveToMem(FIF_PNG, bitmap, &fmh, 0);
53
54 //at this point, fmh.data contains the entire PNG data in memory
55 //fmh.datalen is the amount of space malloc'd for the image in memory,
56 //but only fmh.filelen amount of that space is actually used.
57
58 //its easy load an image from memory as well
59 bitmap2 = FreeImage_LoadFromMem(FIF_PNG, &fmh, 0);
60 //you could also have image data in memory via some other method, and just set
61 //fmh.data to point to it, and set both fmh.datalen and fmh.filelen to the
62 //size of that data, then FreeImage_LoadFromMem could load the image from that
63 //memory
64
65 //make sure to free the data since SaveToMem will cause it to be malloc'd
66 free(fmh.data);
67
68 */
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif

  ViewVC Help
Powered by ViewVC 1.1.26