00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef TEST_OUTPUT_DEVICE_H_
00028 #define TEST_OUTPUT_DEVICE_H_
00029
00030 #include <gtk/gtkwidget.h>
00031 #include <gdk-pixbuf/gdk-pixbuf-core.h>
00032
00033 namespace test
00034 {
00035
00036 #define PLUGIN_ORIENTATION_LANDSCAPE 0
00037 #define PLUGIN_ORIENTATION_PORTRAIT 1
00038
00039 #define MONO_COLOR_DEPTH 8
00040 #define RGB_COLOR_DEPTH 24
00041 #define ARGB_COLOR_DEPTH 32
00042 #define DEFAULT_ALPHA_VALUE 0
00043
00044
00045 struct OutputDeviceContext
00046 {
00047 GtkWidget *widget;
00048 GdkGC *gc;
00049 };
00050
00051
00052 class OutputDevice
00053 {
00054 public:
00055 OutputDevice();
00056 ~OutputDevice(void);
00057
00058
00059 void set_color_depth(int c) {color_dep = c;}
00060
00061
00062
00063 void map(OutputDeviceContext &context);
00064
00065
00066
00067 void invalidate_rectangle(const GdkRectangle &r);
00068
00069
00070
00071 void clear_background(const int color = 0xff, bool flush = false);
00072
00073
00074
00075
00076
00077
00078 void draw_line(int x1, int y1, int x2, int y2);
00079
00080
00081
00082 void draw_highlight_rectangle(const GdkRectangle &rect);
00083
00084
00085
00086
00087
00088
00089
00090
00091 void draw_image(const unsigned char *src,
00092 int width,
00093 int height,
00094 int row_stride,
00095 int xDest = 0,
00096 int yDest = 0);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 void draw_image_with_transform(const unsigned char *src,
00109 int width,
00110 int height,
00111 int row_stride,
00112 int xDest = 0,
00113 int yDest = 0,
00114 int transform = PLUGIN_ORIENTATION_LANDSCAPE);
00115
00116 private:
00117
00118
00119 void update_shared_image(GtkWidget *widget);
00120
00121
00122
00123 void update_shared_image(int width, int height);
00124
00125
00126
00127 bool transform_bitmap_with_same_depth(const unsigned char *src,
00128 unsigned char *dst,
00129 int width,
00130 int height,
00131 int row_stride,
00132 int transform =
00133 PLUGIN_ORIENTATION_PORTRAIT);
00134
00135
00136 bool transform_bitmap_MONO_to_RGB(const unsigned char *src,
00137 unsigned char *dst,
00138 int width,
00139 int height,
00140 int row_stride,
00141 int transform =
00142 PLUGIN_ORIENTATION_PORTRAIT);
00143
00144
00145 bool transform_bitmap_MONO_to_ARGB(const unsigned char *src,
00146 unsigned char *dst,
00147 int width,
00148 int height,
00149 int row_stride,
00150 int transform =
00151 PLUGIN_ORIENTATION_PORTRAIT);
00152
00153
00154 bool transform_bitmap_RGB_to_MONO(const unsigned char *src,
00155 unsigned char *dst,
00156 int width,
00157 int height,
00158 int row_stride,
00159 int transform =
00160 PLUGIN_ORIENTATION_PORTRAIT);
00161
00162
00163 bool transform_bitmap_RGB_to_ARGB(const unsigned char *src,
00164 unsigned char *dst,
00165 int width,
00166 int height,
00167 int row_stride,
00168 int transform =
00169 PLUGIN_ORIENTATION_PORTRAIT);
00170
00171
00172 bool transform_bitmap_ARGB_to_MONO(const unsigned char *src,
00173 unsigned char *dst,
00174 int width,
00175 int height,
00176 int row_stride,
00177 int transform =
00178 PLUGIN_ORIENTATION_PORTRAIT);
00179
00180
00181 bool transform_bitmap_ARGB_to_RGB(const unsigned char *src,
00182 unsigned char *dst,
00183 int width,
00184 int height,
00185 int row_stride,
00186 int transform =
00187 PLUGIN_ORIENTATION_PORTRAIT);
00188
00189 private:
00190
00191 OutputDeviceContext ctx;
00192
00193
00194 GdkImage *shared_image;
00195
00196
00197 int color_dep;
00198
00199
00200 GdkGC *xor_gc;
00201
00202 };
00203
00204 };
00205
00206 #endif
00207
00208