diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/evas/src/modules/engines/software_gdi/evas_gdi_buffer.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/software_gdi/evas_gdi_buffer.c b/libraries/evas/src/modules/engines/software_gdi/evas_gdi_buffer.c new file mode 100644 index 0000000..66a5abf --- /dev/null +++ b/libraries/evas/src/modules/engines/software_gdi/evas_gdi_buffer.c | |||
@@ -0,0 +1,88 @@ | |||
1 | #include <string.h> | ||
2 | |||
3 | #include "evas_common.h" | ||
4 | #include "evas_engine.h" | ||
5 | |||
6 | Gdi_Output_Buffer * | ||
7 | evas_software_gdi_output_buffer_new(HDC dc, | ||
8 | BITMAPINFO_GDI *bitmap_info, | ||
9 | int depth, | ||
10 | int width, | ||
11 | int height, | ||
12 | void *data) | ||
13 | { | ||
14 | Gdi_Output_Buffer *gdiob; | ||
15 | |||
16 | gdiob = calloc(1, sizeof(Gdi_Output_Buffer)); | ||
17 | if (!gdiob) return NULL; | ||
18 | |||
19 | if (!data) | ||
20 | { | ||
21 | bitmap_info->bih.biWidth = width; | ||
22 | bitmap_info->bih.biHeight = -height; | ||
23 | bitmap_info->bih.biSizeImage = (depth >> 3) * width * height; | ||
24 | gdiob->bitmap = CreateDIBSection(dc, | ||
25 | (const BITMAPINFO *)bitmap_info, | ||
26 | DIB_RGB_COLORS, | ||
27 | (void **)(&data), | ||
28 | NULL, | ||
29 | 0); | ||
30 | if (!gdiob->bitmap) | ||
31 | { | ||
32 | free(gdiob); | ||
33 | return NULL; | ||
34 | } | ||
35 | } | ||
36 | |||
37 | gdiob->bitmap_info = bitmap_info; | ||
38 | gdiob->dc = dc; | ||
39 | gdiob->data = data; | ||
40 | gdiob->width = width; | ||
41 | gdiob->height = height; | ||
42 | gdiob->depth = depth; | ||
43 | gdiob->pitch = width * (depth >> 3); | ||
44 | /* gdiob->psize = gdiob->pitch * height; */ | ||
45 | |||
46 | return gdiob; | ||
47 | } | ||
48 | |||
49 | void | ||
50 | evas_software_gdi_output_buffer_free(Gdi_Output_Buffer *gdiob) | ||
51 | { | ||
52 | DeleteObject(gdiob->bitmap); | ||
53 | free(gdiob); | ||
54 | } | ||
55 | |||
56 | void | ||
57 | evas_software_gdi_output_buffer_paste(Gdi_Output_Buffer *gdiob, | ||
58 | int x, | ||
59 | int y) | ||
60 | { | ||
61 | HDC dc; | ||
62 | |||
63 | dc = CreateCompatibleDC(gdiob->dc); | ||
64 | if (!dc) | ||
65 | return; | ||
66 | SelectObject(dc, gdiob->bitmap); | ||
67 | BitBlt(gdiob->dc, | ||
68 | x, y, | ||
69 | gdiob->width, gdiob->height, | ||
70 | dc, | ||
71 | 0, 0, | ||
72 | SRCCOPY); | ||
73 | DeleteDC(dc); | ||
74 | } | ||
75 | |||
76 | DATA8 * | ||
77 | evas_software_gdi_output_buffer_data(Gdi_Output_Buffer *gdiob, | ||
78 | int *pitch) | ||
79 | { | ||
80 | if (pitch) *pitch = gdiob->pitch; | ||
81 | return gdiob->data; | ||
82 | } | ||
83 | |||
84 | int | ||
85 | evas_software_gdi_output_buffer_depth(Gdi_Output_Buffer *gdiob) | ||
86 | { | ||
87 | return gdiob->depth; | ||
88 | } | ||