1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // INTEL CORPORATION PROPRIETARY INFORMATION
4 // This software is supplied under the terms of a license agreement or
5 // nondisclosure agreement with Intel Corporation and may not be copied
6 // or disclosed except in accordance with the terms of that agreement.
7 // Copyright (c) 1999 Intel Corporation. All Rights Reserved.
14 // Authors: Vadim Pisarevsky
20 #pragma warning( disable: 4514 )
21 #pragma warning( disable: 4711 )
23 typedef unsigned char byte;
25 // graphics_format_reader interface
26 class graphics_format_reader
30 graphics_format_reader();
32 int get_signature_length() { return m_sign_len; };
33 const char* get_description() { return m_description; };
34 int get_width() { return m_width; };
35 int get_height() { return m_height; };
37 virtual bool check_format( const char* signature );
38 void set_file( const char* filename );
40 virtual int get_color() = 0;
41 virtual bool read_header() = 0;
42 virtual bool read_data( byte* data, int pitch, int color ) = 0;
43 virtual void close() = 0;
46 int m_width; // width of an image ( filled by read_header )
47 int m_height; // height of an image ( filled by read_header )
48 int m_sign_len; // length of the signature of the format
49 const char* m_signature; // signature of the format
50 const char* m_description; // e.g: Graphics interchange format (*.GIF)
51 char m_filename[1000];
55 typedef struct {} list_position;
57 // list of <graphics_format_reader>s
58 class graphics_format_readers_list
62 graphics_format_readers_list();
63 ~graphics_format_readers_list();
64 void remove_all_readers();
65 void add_reader( graphics_format_reader* reader );
66 int readers_count() { return m_cur_readers; };
67 list_position* get_first_reader_pos();
68 graphics_format_reader* get_next_reader( list_position*& pos );
69 graphics_format_reader* find_reader( const char* filename );
70 int get_filters_string( char* buffer, int maxlen );
74 graphics_format_reader** m_readers;
81 unsigned char b,g,r,a;
84 #define WRITE_PIX( ptr, clr ) \
85 (((byte*)(ptr))[0] = (clr).b, \
86 ((byte*)(ptr))[1] = (clr).g, \
87 ((byte*)(ptr))[2] = (clr).r)
89 #define descale(x,n) (((x) + (1 << ((n)-1))) >> (n))
90 #define saturate(x) (byte)(((x) & ~255) == 0 ? (x) : ~((x)>>31))
92 void cvt_bgr_to_gray( byte* bgr, byte* gray, int len );
93 void cvt_palette_to_gray( palette_entry* palette, byte* gray_palette, int entries );