/[projet1]/public/pc/tools/osdk/main/pictconv/sources/oric_converter.h
Defence Force logotype

Contents of /public/pc/tools/osdk/main/pictconv/sources/oric_converter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 974 - (show annotations)
Sun Nov 24 13:29:03 2013 UTC (5 years, 11 months ago) by dbug
File MIME type: text/plain
File size: 4320 byte(s)
Did some minor API changes in the Common library (returned a string by value instead of reference)
Added also a new project called 'Ym2Mym' which is not from me, but that all the MYM demos are using to convert Atari ST music.
Updated FreeImage from 3.9.3 to 3.15.4 (only used by PictConv)
PictConv now has a CharacterGenerator mode, not quite sure yet that it works.
1 #ifndef ORIC_CONVERTER_H
2 #define ORIC_CONVERTER_H
3
4 #include "hires.h"
5
6 enum ORIC_COLOR
7 { // BGR
8 ORIC_COLOR_BLACK, // 000
9 ORIC_COLOR_RED, // 001
10 ORIC_COLOR_GREEN, // 010
11 ORIC_COLOR_YELLOW, // 011
12 ORIC_COLOR_BLUE, // 100
13 ORIC_COLOR_MAGENTA, // 101
14 ORIC_COLOR_CYAN, // 110
15 ORIC_COLOR_WHITE, // 111
16 _ORIC_COLOR_LAST_
17 };
18
19 class GeneratedBuffer
20 {
21 public:
22 GeneratedBuffer() :
23 m_buffer(0),
24 m_buffer_size(0),
25 m_buffer_width(0),
26 m_buffer_height(0),
27 m_buffer_cols(0)
28 {
29 }
30
31 ~GeneratedBuffer()
32 {
33 delete[] m_buffer;
34 }
35
36
37 void SetBufferSize(int width,int height)
38 {
39 m_buffer_width =width;
40 m_buffer_height =height;
41 m_buffer_cols =(width+5)/6;
42 m_buffer_size =m_buffer_height*m_buffer_cols;
43
44 delete[] m_buffer;
45 m_buffer=new unsigned char[m_buffer_size];
46 }
47
48
49
50 void ClearBuffer(bool setBit6)
51 {
52 //
53 // Fill the screen with a neutral value (64=white space for hires)
54 //
55 unsigned char fillValue;
56 if (setBit6)
57 {
58 fillValue=64;
59 }
60 else
61 {
62 fillValue=0;
63 }
64 for (unsigned int i=0;i<m_buffer_size;i++)
65 {
66 m_buffer[i]=fillValue;
67 }
68 }
69
70 virtual unsigned char *GetBufferData() { return m_buffer; }
71 virtual unsigned int GetBufferSize() { return m_buffer_size; }
72
73 unsigned int get_buffer_width() const { return m_buffer_width; }
74 unsigned int get_buffer_height() const { return m_buffer_height; }
75
76 void SetName(const std::string& name) { m_Name=name; }
77 const std::string& GetName() const { return m_Name; }
78
79 public:
80 std::string m_Name;
81 unsigned char* m_buffer;
82 unsigned int m_buffer_size;
83 unsigned int m_buffer_width;
84 unsigned int m_buffer_height;
85 int m_buffer_cols;
86 };
87
88
89 class OricPictureConverter : public PictureConverter
90 {
91 friend class PictureConverter;
92
93 public:
94 enum FORMAT
95 {
96 FORMAT_MONOCHROM, // -f0 / -f0z
97 FORMAT_COLORED, // -f1
98 FORMAT_RGB, // -f2
99 FORMAT_TWILIGHTE_MASK, // -f3
100 FORMAT_RB, // -f4
101 FORMAT_CHARMAP, // -f5
102 _FORMAT_MAX_
103 };
104
105 public:
106 virtual int GetFormat() const { return (int)m_format; }
107 virtual bool SetFormat(int format) { m_format=(FORMAT)format;return m_format<_FORMAT_MAX_; }
108
109 virtual int GetPaletteMode() const { return 0; }
110 virtual bool SetPaletteMode(int paletteMode) { return paletteMode==0; }
111
112 virtual bool Convert(const ImageContainer& sourcePicture);
113 virtual bool TakeSnapShot(ImageContainer& sourcePicture);
114
115 virtual void SaveToFile(long handle,int output_format);
116
117 bool get_bit6() { return m_flag_setbit6; }
118 void set_bit6(bool flag_value) { m_flag_setbit6=flag_value; }
119
120 void convert_monochrom(const ImageContainer& sourcePicture);
121 void convert_colored(const ImageContainer& sourcePicture);
122 void convert_rgb(const ImageContainer& sourcePicture);
123 void convert_rb(const ImageContainer& sourcePicture);
124 void convert_twilighte_mask(const ImageContainer& sourcePicture);
125 void convert_charmap(const ImageContainer& sourcePicture);
126
127 ORIC_COLOR convert_pixel_monochrom(const ImageContainer& sourcePicture,unsigned int x,unsigned int y);
128 ORIC_COLOR convert_pixel_rgb(const ImageContainer& sourcePicture,unsigned int x,unsigned int y);
129 ORIC_COLOR convert_pixel_rb(const ImageContainer& sourcePicture,unsigned int x,unsigned int y);
130
131 void save_header(long handle,int adress_begin);
132
133 virtual unsigned char *GetBufferData() { return m_Buffer.GetBufferData(); }
134 virtual unsigned int GetBufferSize() { return m_Buffer.GetBufferSize(); }
135
136 virtual unsigned char *GetSecondaryBufferData() { return m_SecondaryBuffer.GetBufferData(); }
137 virtual unsigned int GetSecondaryBufferSize() { return m_SecondaryBuffer.GetBufferSize(); }
138
139 unsigned int get_buffer_width() { return m_Buffer.get_buffer_width(); }
140 unsigned int get_buffer_height() { return m_Buffer.get_buffer_height(); }
141
142 protected:
143 OricPictureConverter();
144 virtual ~OricPictureConverter();
145
146 private:
147 GeneratedBuffer m_Buffer;
148 GeneratedBuffer m_SecondaryBuffer;
149
150 FORMAT m_format;
151
152 bool m_flag_setbit6;
153 };
154
155 #endif

  ViewVC Help
Powered by ViewVC 1.1.26