Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
jpeg_memory.h
Go to the documentation of this file.
1 #include <stdio.h>
2 #define JPEG_SUPPORT
3 #ifdef JPEG_SUPPORT /* Always true? */
4 #ifndef __JPEG_MEMORY_H
5 #define __JPEG_MEMORY_H
6 #include <string.h>
7 /* BAD BAD!!
8  * #if defined( _WIN32) && !defined( __CYGWIN__)
9  * #ifndef HAVE_BOOLEAN
10  * #define HAVE_BOOLEAN
11  * #define FALSE 0
12  * #define TRUE 1
13  * typedef unsigned char boolean;
14  * #endif
15  * #ifndef XMD_H
16  * #define XMD_H
17  * typedef int INT32;
18  * #endif
19  * #endif
20  */
21 #if defined (_WIN32) && !defined (__CYGWIN__)
22 #ifndef NOMINMAX
23 #define NOMINMAX
24 #endif //tells VCC not to generate min/max macros
25 #include <windows.h>
26 #endif
27 #include "vsfilesystem.h"
28 #ifdef _WIN32
29 #define XMD_H
30 #undef HAVE_BOOLEAN
31 #define boolean boolean1
32 #endif
33 extern "C" {
34 //#define XMD_H
35 #include <jconfig.h>
36 #include <jmorecfg.h>
37 #include <jpeglib.h>
38 }
39 /*--------------
40  * A hack to hijack JPEG's innards to write into a memory buffer
41  * ----------------
42  * / this defines a new destination manager to store images in memory
43  * / derived by jdatadst.c */
44 typedef struct
45 {
46  struct jpeg_destination_mgr pub; /* public fields */
47  JOCTET *buffer; /* start of buffer */
48  int bufsize; /* buffer size */
49  int datacount; /* finale data size */
51 
53 
54 /*----------------------------------------------------------------------------
55  * / Initialize destination --- called by jpeg_start_compress before any data is actually written. */
56 
57 METHODDEF( void )
58 init_destination( j_compress_ptr cinfo )
59 {
60  mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
61  dest->pub.next_output_byte = dest->buffer;
62  dest->pub.free_in_buffer = dest->bufsize;
63  dest->datacount = 0;
64 }
65 
66 /*----------------------------------------------------------------------------
67  * / Empty the output buffer --- called whenever buffer fills up. */
68 METHODDEF( boolean )
69 empty_output_buffer( j_compress_ptr cinfo )
70 {
71  mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
72  dest->pub.next_output_byte = dest->buffer;
73  dest->pub.free_in_buffer = dest->bufsize;
74 
75  return TRUE;
76 }
77 
78 /*----------------------------------------------------------------------------
79  * / Terminate destination --- called by jpeg_finish_compress
80  * / after all data has been written. Usually needs to flush buffer. */
81 METHODDEF( void )
82 term_destination( j_compress_ptr cinfo )
83 {
84  /* expose the finale compressed image size */
85 
86  mem_dest_ptr dest = (mem_dest_ptr) cinfo->dest;
87  dest->datacount = dest->bufsize-dest->pub.free_in_buffer;
88 }
89 
90 GLOBAL( void ) jpeg_memory_dest( j_compress_ptr cinfo, JOCTET*buffer, int bufsize );
91 int jpeg_compress( char *dst, char *src, int width, int height, int dstsize, int quality );
92 int jpeg_compress_to_file( char *src, char *file, int width, int height, int quality );
93 extern void jpeg_memory_src( j_decompress_ptr cinfo, unsigned char *ptr, size_t size );
94 void jpeg_decompress( unsigned char *dst, unsigned char *src, int size, int *w, int *h );
95 void jpeg_decompress_from_file( unsigned char *dst, char *file, int size, int *w, int *h );
96 
97 #endif
98 #endif
99