FreeBASIC  0.91.0
gfx_put_custom.c
Go to the documentation of this file.
1 /* CUSTOM drawing method for PUT statement */
2 
3 #include "fb_gfx.h"
4 
5 
6 /*:::::*/
7 static void fb_hPutCustom1(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
8 {
9  unsigned char *s = (unsigned char *)src;
10  unsigned char *d;
11  int x;
12 
13  src_pitch -= w;
14  for (; h; h--) {
15  d = (unsigned char *)dest;
16  for (x = w; x; x--) {
17  *d = (unsigned char)blender((unsigned int)*s, (unsigned int)*d, param);
18  s++;
19  d++;
20  }
21  s += src_pitch;
22  dest += dest_pitch;
23  }
24 }
25 
26 
27 /*:::::*/
28 static void fb_hPutCustom2(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
29 {
30  unsigned short *s = (unsigned short *)src;
31  unsigned short *d;
32  int x;
33  unsigned int cs, cd;
34 
35  src_pitch = (src_pitch >> 1) - w;
36  for (; h; h--) {
37  d = (unsigned short *)dest;
38  for (x = w; x; x--) {
39  cs = *s++;
40  cs = (((cs & 0x001F) << 3) | ((cs >> 2) & 0x7) |
41  ((cs & 0x07E0) << 5) | ((cs >> 1) & 0x300) |
42  ((cs & 0xF800) << 8) | ((cs << 3) & 0x70000));
43  cd = *d;
44  cd = (((cd & 0x001F) << 3) | ((cd >> 2) & 0x7) |
45  ((cd & 0x07E0) << 5) | ((cd >> 1) & 0x300) |
46  ((cd & 0xF800) << 8) | ((cd << 3) & 0x70000));
47  cd = blender(cs, cd, param);
48  *d++ = (unsigned short)((cd >> 3) & 0x001F) | ((cd >> 5) & 0x07E0) | ((cd >> 8) & 0xF800);
49  }
50  s += src_pitch;
51  dest += dest_pitch;
52  }
53 }
54 
55 
56 /*:::::*/
57 static void fb_hPutCustom4(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
58 {
59  unsigned int *s = (unsigned int *)src;
60  unsigned int *d;
61  int x;
62 
63  src_pitch = (src_pitch >> 2) - w;
64  for (; h; h--) {
65  d = (unsigned int *)dest;
66  for (x = w; x; x--) {
67  *d = blender(*s, *d, param);
68  s++;
69  d++;
70  }
71  s += src_pitch;
72  dest += dest_pitch;
73  }
74 }
75 
76 
77 /*:::::*/
78 void fb_hPutCustom(unsigned char *src, unsigned char *dest, int w, int h, int src_pitch, int dest_pitch, int alpha, BLENDER *blender, void *param)
79 {
80  static PUTTER *all_putters[] = {
82  };
83  PUTTER *putter;
85 
86  if (!context->putter[PUT_MODE_CUSTOM]) {
87  context->putter[PUT_MODE_CUSTOM] = &all_putters[0];
88  }
89  putter = context->putter[PUT_MODE_CUSTOM][context->target_bpp - 1];
90 
91  putter(src, dest, w, h, src_pitch, dest_pitch, alpha, blender, param);
92 }