Debian Codegraph @

extern/agg24-svn/include/agg_pixfmt_rgb.h

raw
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: [email protected]
12 // [email protected]
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // Adaptation for high precision colors has been sponsored by
17 // Liberty Technology Systems, Inc., visit http://lib-sys.com
18 //
19 // Liberty Technology Systems, Inc. is the provider of
20 // PostScript and PDF technology for software developers.
21 //
22 //----------------------------------------------------------------------------
23
24 #ifndef AGG_PIXFMT_RGB_INCLUDED
25 #define AGG_PIXFMT_RGB_INCLUDED
26
27 #include <string.h>
28 #include "agg_pixfmt_base.h"
29 #include "agg_rendering_buffer.h"
30
31 namespace agg
32 {
33
34 //=====================================================apply_gamma_dir_rgb
35 template<class ColorT, class Order, class GammaLut> class apply_gamma_dir_rgb
36 {
37 public:
38 typedef typename ColorT::value_type value_type;
39
40 apply_gamma_dir_rgb(const GammaLut& gamma) : m_gamma(gamma) {}
41
42 AGG_INLINE void operator () (value_type* p)
43 {
44 p[Order::R] = m_gamma.dir(p[Order::R]);
45 p[Order::G] = m_gamma.dir(p[Order::G]);
46 p[Order::B] = m_gamma.dir(p[Order::B]);
47 }
48
49 private:
50 const GammaLut& m_gamma;
51 };
52
53
54
55 //=====================================================apply_gamma_inv_rgb
56 template<class ColorT, class Order, class GammaLut> class apply_gamma_inv_rgb
57 {
58 public:
59 typedef typename ColorT::value_type value_type;
60
61 apply_gamma_inv_rgb(const GammaLut& gamma) : m_gamma(gamma) {}
62
63 AGG_INLINE void operator () (value_type* p)
64 {
65 p[Order::R] = m_gamma.inv(p[Order::R]);
66 p[Order::G] = m_gamma.inv(p[Order::G]);
67 p[Order::B] = m_gamma.inv(p[Order::B]);
68 }
69
70 private:
71 const GammaLut& m_gamma;
72 };
73
74
75 //=========================================================blender_rgb
76 template<class ColorT, class Order>
77 struct blender_rgb
78 {
79 typedef ColorT color_type;
80 typedef Order order_type;
81 typedef typename color_type::value_type value_type;
82 typedef typename color_type::calc_type calc_type;
83 typedef typename color_type::long_type long_type;
84
85 // Blend pixels using the non-premultiplied form of Alvy-Ray Smith's
86 // compositing function. Since the render buffer is opaque we skip the
87 // initial premultiply and final demultiply.
88
89 //--------------------------------------------------------------------
90 static AGG_INLINE void blend_pix(value_type* p,
91 value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover)
92 {
93 blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover));
94 }
95
96 //--------------------------------------------------------------------
97 static AGG_INLINE void blend_pix(value_type* p,
98 value_type cr, value_type cg, value_type cb, value_type alpha)
99 {
100 p[Order::R] = color_type::lerp(p[Order::R], cr, alpha);
101 p[Order::G] = color_type::lerp(p[Order::G], cg, alpha);
102 p[Order::B] = color_type::lerp(p[Order::B], cb, alpha);
103 }
104 };
105
106 //======================================================blender_rgb_pre
107 template<class ColorT, class Order>
108 struct blender_rgb_pre
109 {
110 typedef ColorT color_type;
111 typedef Order order_type;
112 typedef typename color_type::value_type value_type;
113 typedef typename color_type::calc_type calc_type;
114 typedef typename color_type::long_type long_type;
115
116 // Blend pixels using the premultiplied form of Alvy-Ray Smith's
117 // compositing function.
118
119 //--------------------------------------------------------------------
120 static AGG_INLINE void blend_pix(value_type* p,
121 value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover)
122 {
123 blend_pix(p,
124 color_type::mult_cover(cr, cover),
125 color_type::mult_cover(cg, cover),
126 color_type::mult_cover(cb, cover),
127 color_type::mult_cover(alpha, cover));
128 }
129
130 //--------------------------------------------------------------------
131 static AGG_INLINE void blend_pix(value_type* p,
132 value_type cr, value_type cg, value_type cb, value_type alpha)
133 {
134 p[Order::R] = color_type::prelerp(p[Order::R], cr, alpha);
135 p[Order::G] = color_type::prelerp(p[Order::G], cg, alpha);
136 p[Order::B] = color_type::prelerp(p[Order::B], cb, alpha);
137 }
138 };
139
140 //===================================================blender_rgb_gamma
141 template<class ColorT, class Order, class Gamma>
142 class blender_rgb_gamma : public blender_base<ColorT, Order>
143 {
144 public:
145 typedef ColorT color_type;
146 typedef Order order_type;
147 typedef Gamma gamma_type;
148 typedef typename color_type::value_type value_type;
149 typedef typename color_type::calc_type calc_type;
150 typedef typename color_type::long_type long_type;
151
152 //--------------------------------------------------------------------
153 blender_rgb_gamma() : m_gamma(0) {}
154 void gamma(const gamma_type& g) { m_gamma = &g; }
155
156 //--------------------------------------------------------------------
157 AGG_INLINE void blend_pix(value_type* p,
158 value_type cr, value_type cg, value_type cb, value_type alpha, cover_type cover)
159 {
160 blend_pix(p, cr, cg, cb, color_type::mult_cover(alpha, cover));
161 }
162
163 //--------------------------------------------------------------------
164 AGG_INLINE void blend_pix(value_type* p,
165 value_type cr, value_type cg, value_type cb, value_type alpha)
166 {
167 calc_type r = m_gamma->dir(p[Order::R]);
168 calc_type g = m_gamma->dir(p[Order::G]);
169 calc_type b = m_gamma->dir(p[Order::B]);
170 p[Order::R] = m_gamma->inv(color_type::downscale((m_gamma->dir(cr) - r) * alpha) + r);
171 p[Order::G] = m_gamma->inv(color_type::downscale((m_gamma->dir(cg) - g) * alpha) + g);
172 p[Order::B] = m_gamma->inv(color_type::downscale((m_gamma->dir(cb) - b) * alpha) + b);
173 }
174
175 private:
176 const gamma_type* m_gamma;
177 };
178
179
180 //==================================================pixfmt_alpha_blend_rgb
181 template<class Blender, class RenBuf, unsigned Step, unsigned Offset = 0>
182 class pixfmt_alpha_blend_rgb
183 {
184 public:
185 typedef pixfmt_rgb_tag pixfmt_category;
186 typedef RenBuf rbuf_type;
187 typedef Blender blender_type;
188 typedef typename rbuf_type::row_data row_data;
189 typedef typename blender_type::color_type color_type;
190 typedef typename blender_type::order_type order_type;
191 typedef typename color_type::value_type value_type;
192 typedef typename color_type::calc_type calc_type;
193 enum
194 {
195 pix_step = Step,
196 pix_offset = Offset,
197 pix_width = sizeof(value_type) * pix_step
198 };
199 struct pixel_type
200 {
201 value_type c[pix_step];
202
203 void set(value_type r, value_type g, value_type b)
204 {
205 c[order_type::R] = r;
206 c[order_type::G] = g;
207 c[order_type::B] = b;
208 }
209
210 void set(const color_type& color)
211 {
212 set(color.r, color.g, color.b);
213 }
214
215 void get(value_type& r, value_type& g, value_type& b) const
216 {
217 r = c[order_type::R];
218 g = c[order_type::G];
219 b = c[order_type::B];
220 }
221
222 color_type get() const
223 {
224 return color_type(
225 c[order_type::R],
226 c[order_type::G],
227 c[order_type::B]);
228 }
229
230 pixel_type* next()
231 {
232 return this + 1;
233 }
234
235 const pixel_type* next() const
236 {
237 return this + 1;
238 }
239
240 pixel_type* advance(int n)
241 {
242 return this + n;
243 }
244
245 const pixel_type* advance(int n) const
246 {
247 return this + n;
248 }
249 };
250
251 private:
252 //--------------------------------------------------------------------
253 AGG_INLINE void blend_pix(pixel_type* p,
254 value_type r, value_type g, value_type b, value_type a,
255 unsigned cover)
256 {
257 m_blender.blend_pix(p->c, r, g, b, a, cover);
258 }
259
260 //--------------------------------------------------------------------
261 AGG_INLINE void blend_pix(pixel_type* p,
262 value_type r, value_type g, value_type b, value_type a)
263 {
264 m_blender.blend_pix(p->c, r, g, b, a);
265 }
266
267 //--------------------------------------------------------------------
268 AGG_INLINE void blend_pix(pixel_type* p, const color_type& c, unsigned cover)
269 {
270 m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a, cover);
271 }
272
273 //--------------------------------------------------------------------
274 AGG_INLINE void blend_pix(pixel_type* p, const color_type& c)
275 {
276 m_blender.blend_pix(p->c, c.r, c.g, c.b, c.a);
277 }
278
279 //--------------------------------------------------------------------
280 AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover)
281 {
282 if (!c.is_transparent())
283 {
284 if (c.is_opaque() && cover == cover_mask)
285 {
286 p->set(c);
287 }
288 else
289 {
290 blend_pix(p, c, cover);
291 }
292 }
293 }
294
295 //--------------------------------------------------------------------
296 AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c)
297 {
298 if (!c.is_transparent())
299 {
300 if (c.is_opaque())
301 {
302 p->set(c);
303 }
304 else
305 {
306 blend_pix(p, c);
307 }
308 }
309 }
310
311 public:
312 //--------------------------------------------------------------------
313 explicit pixfmt_alpha_blend_rgb(rbuf_type& rb) :
314 m_rbuf(&rb)
315 {}
316 void attach(rbuf_type& rb) { m_rbuf = &rb; }
317
318 //--------------------------------------------------------------------
319 template<class PixFmt>
320 bool attach(PixFmt& pixf, int x1, int y1, int x2, int y2)
321 {
322 rect_i r(x1, y1, x2, y2);
323 if (r.clip(rect_i(0, 0, pixf.width()-1, pixf.height()-1)))
324 {
325 int stride = pixf.stride();
326 m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1),
327 (r.x2 - r.x1) + 1,
328 (r.y2 - r.y1) + 1,
329 stride);
330 return true;
331 }
332 return false;
333 }
334
335 //--------------------------------------------------------------------
336 Blender& blender() { return m_blender; }
337
338 //--------------------------------------------------------------------
339 AGG_INLINE unsigned width() const { return m_rbuf->width(); }
340 AGG_INLINE unsigned height() const { return m_rbuf->height(); }
341 AGG_INLINE int stride() const { return m_rbuf->stride(); }
342
343 //--------------------------------------------------------------------
344 AGG_INLINE int8u* row_ptr(int y) { return m_rbuf->row_ptr(y); }
345 AGG_INLINE const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); }
346 AGG_INLINE row_data row(int y) const { return m_rbuf->row(y); }
347
348 //--------------------------------------------------------------------
349 AGG_INLINE int8u* pix_ptr(int x, int y)
350 {
351 return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset);
352 }
353
354 AGG_INLINE const int8u* pix_ptr(int x, int y) const
355 {
356 return m_rbuf->row_ptr(y) + sizeof(value_type) * (x * pix_step + pix_offset);
357 }
358
359 // Return pointer to pixel value, forcing row to be allocated.
360 AGG_INLINE pixel_type* pix_value_ptr(int x, int y, unsigned len)
361 {
362 return (pixel_type*)(m_rbuf->row_ptr(x, y, len) + sizeof(value_type) * (x * pix_step + pix_offset));
363 }
364
365 // Return pointer to pixel value, or null if row not allocated.
366 AGG_INLINE const pixel_type* pix_value_ptr(int x, int y) const
367 {
368 int8u* p = m_rbuf->row_ptr(y);
369 return p ? (pixel_type*)(p + sizeof(value_type) * (x * pix_step + pix_offset)) : 0;
370 }
371
372 // Get pixel pointer from raw buffer pointer.
373 AGG_INLINE static pixel_type* pix_value_ptr(void* p)
374 {
375 return (pixel_type*)((value_type*)p + pix_offset);
376 }
377
378 // Get pixel pointer from raw buffer pointer.
379 AGG_INLINE static const pixel_type* pix_value_ptr(const void* p)
380 {
381 return (const pixel_type*)((const value_type*)p + pix_offset);
382 }
383
384 //--------------------------------------------------------------------
385 AGG_INLINE static void write_plain_color(void* p, color_type c)
386 {
387 // RGB formats are implicitly premultiplied.
388 c.premultiply();
389 pix_value_ptr(p)->set(c);
390 }
391
392 //--------------------------------------------------------------------
393 AGG_INLINE static color_type read_plain_color(const void* p)
394 {
395 return pix_value_ptr(p)->get();
396 }
397
398 //--------------------------------------------------------------------
399 AGG_INLINE static void make_pix(int8u* p, const color_type& c)
400 {
401 ((pixel_type*)p)->set(c);
402 }
403
404 //--------------------------------------------------------------------
405 AGG_INLINE color_type pixel(int x, int y) const
406 {
407 if (const pixel_type* p = pix_value_ptr(x, y))
408 {
409 return p->get();
410 }
411 return color_type::no_color();
412 }
413
414 //--------------------------------------------------------------------
415 AGG_INLINE void copy_pixel(int x, int y, const color_type& c)
416 {
417 pix_value_ptr(x, y, 1)->set(c);
418 }
419
420 //--------------------------------------------------------------------
421 AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover)
422 {
423 copy_or_blend_pix(pix_value_ptr(x, y, 1), c, cover);
424 }
425
426 //--------------------------------------------------------------------
427 AGG_INLINE void copy_hline(int x, int y,
428 unsigned len,
429 const color_type& c)
430 {
431 pixel_type* p = pix_value_ptr(x, y, len);
432 do
433 {
434 p->set(c);
435 p = p->next();
436 }
437 while(--len);
438 }
439
440
441 //--------------------------------------------------------------------
442 AGG_INLINE void copy_vline(int x, int y,
443 unsigned len,
444 const color_type& c)
445 {
446 do
447 {
448 pix_value_ptr(x, y++, 1)->set(c);
449 }
450 while (--len);
451 }
452
453 //--------------------------------------------------------------------
454 void blend_hline(int x, int y,
455 unsigned len,
456 const color_type& c,
457 int8u cover)
458 {
459 if (!c.is_transparent())
460 {
461 pixel_type* p = pix_value_ptr(x, y, len);
462
463 if (c.is_opaque() && cover == cover_mask)
464 {
465 do
466 {
467 p->set(c);
468 p = p->next();
469 }
470 while (--len);
471 }
472 else
473 {
474 do
475 {
476 blend_pix(p, c, cover);
477 p = p->next();
478 }
479 while (--len);
480 }
481 }
482 }
483
484
485 //--------------------------------------------------------------------
486 void blend_vline(int x, int y,
487 unsigned len,
488 const color_type& c,
489 int8u cover)
490 {
491 if (!c.is_transparent())
492 {
493 if (c.is_opaque() && cover == cover_mask)
494 {
495 do
496 {
497 pix_value_ptr(x, y++, 1)->set(c);
498 }
499 while (--len);
500 }
501 else
502 {
503 do
504 {
505 blend_pix(pix_value_ptr(x, y++, 1), c, cover);
506 }
507 while (--len);
508 }
509 }
510 }
511
512 //--------------------------------------------------------------------
513 void blend_solid_hspan(int x, int y,
514 unsigned len,
515 const color_type& c,
516 const int8u* covers)
517 {
518 if (!c.is_transparent())
519 {
520 pixel_type* p = pix_value_ptr(x, y, len);
521
522 do
523 {
524 if (c.is_opaque() && *covers == cover_mask)
525 {
526 p->set(c);
527 }
528 else
529 {
530 blend_pix(p, c, *covers);
531 }
532 p = p->next();
533 ++covers;
534 }
535 while (--len);
536 }
537 }
538
539
540 //--------------------------------------------------------------------
541 void blend_solid_vspan(int x, int y,
542 unsigned len,
543 const color_type& c,
544 const int8u* covers)
545 {
546 if (!c.is_transparent())
547 {
548 do
549 {
550 pixel_type* p = pix_value_ptr(x, y++, 1);
551
552 if (c.is_opaque() && *covers == cover_mask)
553 {
554 p->set(c);
555 }
556 else
557 {
558 blend_pix(p, c, *covers);
559 }
560 ++covers;
561 }
562 while (--len);
563 }
564 }
565
566 //--------------------------------------------------------------------
567 void copy_color_hspan(int x, int y,
568 unsigned len,
569 const color_type* colors)
570 {
571 pixel_type* p = pix_value_ptr(x, y, len);
572
573 do
574 {
575 p->set(*colors++);
576 p = p->next();
577 }
578 while (--len);
579 }
580
581
582 //--------------------------------------------------------------------
583 void copy_color_vspan(int x, int y,
584 unsigned len,
585 const color_type* colors)
586 {
587 do
588 {
589 pix_value_ptr(x, y++, 1)->set(*colors++);
590 }
591 while (--len);
592 }
593
594 //--------------------------------------------------------------------
595 void blend_color_hspan(int x, int y,
596 unsigned len,
597 const color_type* colors,
598 const int8u* covers,
599 int8u cover)
600 {
601 pixel_type* p = pix_value_ptr(x, y, len);
602
603 if (covers)
604 {
605 do
606 {
607 copy_or_blend_pix(p, *colors++, *covers++);
608 p = p->next();
609 }
610 while (--len);
611 }
612 else
613 {
614 if (cover == cover_mask)
615 {
616 do
617 {
618 copy_or_blend_pix(p, *colors++);
619 p = p->next();
620 }
621 while (--len);
622 }
623 else
624 {
625 do
626 {
627 copy_or_blend_pix(p, *colors++, cover);
628 p = p->next();
629 }
630 while (--len);
631 }
632 }
633 }
634
635 //--------------------------------------------------------------------
636 void blend_color_vspan(int x, int y,
637 unsigned len,
638 const color_type* colors,
639 const int8u* covers,
640 int8u cover)
641 {
642 if (covers)
643 {
644 do
645 {
646 copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, *covers++);
647 }
648 while (--len);
649 }
650 else
651 {
652 if (cover == cover_mask)
653 {
654 do
655 {
656 copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++);
657 }
658 while (--len);
659 }
660 else
661 {
662 do
663 {
664 copy_or_blend_pix(pix_value_ptr(x, y++, 1), *colors++, cover);
665 }
666 while (--len);
667 }
668 }
669 }
670
671 //--------------------------------------------------------------------
672 template<class Function> void for_each_pixel(Function f)
673 {
674 for (unsigned y = 0; y < height(); ++y)
675 {
676 row_data r = m_rbuf->row(y);
677 if (r.ptr)
678 {
679 unsigned len = r.x2 - r.x1 + 1;
680 pixel_type* p = pix_value_ptr(r.x1, y, len);
681 do
682 {
683 f(p->c);
684 p = p->next();
685 }
686 while (--len);
687 }
688 }
689 }
690
691 //--------------------------------------------------------------------
692 template<class GammaLut> void apply_gamma_dir(const GammaLut& g)
693 {
694 for_each_pixel(apply_gamma_dir_rgb<color_type, order_type, GammaLut>(g));
695 }
696
697 //--------------------------------------------------------------------
698 template<class GammaLut> void apply_gamma_inv(const GammaLut& g)
699 {
700 for_each_pixel(apply_gamma_inv_rgb<color_type, order_type, GammaLut>(g));
701 }
702
703 //--------------------------------------------------------------------
704 template<class RenBuf2>
705 void copy_from(const RenBuf2& from,
706 int xdst, int ydst,
707 int xsrc, int ysrc,
708 unsigned len)
709 {
710 if (const int8u* p = from.row_ptr(ysrc))
711 {
712 memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,
713 p + xsrc * pix_width,
714 len * pix_width);
715 }
716 }
717
718 //--------------------------------------------------------------------
719 // Blend from an RGBA surface.
720 template<class SrcPixelFormatRenderer>
721 void blend_from(const SrcPixelFormatRenderer& from,
722 int xdst, int ydst,
723 int xsrc, int ysrc,
724 unsigned len,
725 int8u cover)
726 {
727 typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type;
728 typedef typename SrcPixelFormatRenderer::order_type src_order;
729
730 if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc))
731 {
732 pixel_type* pdst = pix_value_ptr(xdst, ydst, len);
733
734 if (cover == cover_mask)
735 {
736 do
737 {
738 value_type alpha = psrc->c[src_order::A];
739 if (alpha <= color_type::empty_value())
740 {
741 if (alpha >= color_type::full_value())
742 {
743 pdst->c[order_type::R] = psrc->c[src_order::R];
744 pdst->c[order_type::G] = psrc->c[src_order::G];
745 pdst->c[order_type::B] = psrc->c[src_order::B];
746 }
747 else
748 {
749 blend_pix(pdst,
750 psrc->c[src_order::R],
751 psrc->c[src_order::G],
752 psrc->c[src_order::B],
753 alpha);
754 }
755 }
756 psrc = psrc->next();
757 pdst = pdst->next();
758 }
759 while(--len);
760 }
761 else
762 {
763 do
764 {
765 copy_or_blend_pix(pdst, psrc->get(), cover);
766 psrc = psrc->next();
767 pdst = pdst->next();
768 }
769 while (--len);
770 }
771 }
772 }
773
774 //--------------------------------------------------------------------
775 // Blend from single color, using grayscale surface as alpha channel.
776 template<class SrcPixelFormatRenderer>
777 void blend_from_color(const SrcPixelFormatRenderer& from,
778 const color_type& color,
779 int xdst, int ydst,
780 int xsrc, int ysrc,
781 unsigned len,
782 int8u cover)
783 {
784 typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type;
785 typedef typename SrcPixelFormatRenderer::color_type src_color_type;
786
787 if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc))
788 {
789 pixel_type* pdst = pix_value_ptr(xdst, ydst, len);
790
791 do
792 {
793 copy_or_blend_pix(pdst, color, src_color_type::scale_cover(cover, psrc->c[0]));
794 psrc = psrc->next();
795 pdst = pdst->next();
796 }
797 while (--len);
798 }
799 }
800
801 //--------------------------------------------------------------------
802 // Blend from color table, using grayscale surface as indexes into table.
803 // Obviously, this only works for integer value types.
804 template<class SrcPixelFormatRenderer>
805 void blend_from_lut(const SrcPixelFormatRenderer& from,
806 const color_type* color_lut,
807 int xdst, int ydst,
808 int xsrc, int ysrc,
809 unsigned len,
810 int8u cover)
811 {
812 typedef typename SrcPixelFormatRenderer::pixel_type src_pixel_type;
813
814 if (const src_pixel_type* psrc = from.pix_value_ptr(xsrc, ysrc))
815 {
816 pixel_type* pdst = pix_value_ptr(xdst, ydst, len);
817
818 if (cover == cover_mask)
819 {
820 do
821 {
822 const color_type& color = color_lut[psrc->c[0]];
823 blend_pix(pdst, color);
824 psrc = psrc->next();
825 pdst = pdst->next();
826 }
827 while(--len);
828 }
829 else
830 {
831 do
832 {
833 copy_or_blend_pix(pdst, color_lut[psrc->c[0]], cover);
834 psrc = psrc->next();
835 pdst = pdst->next();
836 }
837 while(--len);
838 }
839 }
840 }
841
842 private:
843 rbuf_type* m_rbuf;
844 Blender m_blender;
845 };
846
847 //-----------------------------------------------------------------------
848 typedef blender_rgb<rgba8, order_rgb> blender_rgb24;
849 typedef blender_rgb<rgba8, order_bgr> blender_bgr24;
850 typedef blender_rgb<srgba8, order_rgb> blender_srgb24;
851 typedef blender_rgb<srgba8, order_bgr> blender_sbgr24;
852 typedef blender_rgb<rgba16, order_rgb> blender_rgb48;
853 typedef blender_rgb<rgba16, order_bgr> blender_bgr48;
854 typedef blender_rgb<rgba32, order_rgb> blender_rgb96;
855 typedef blender_rgb<rgba32, order_bgr> blender_bgr96;
856
857 typedef blender_rgb_pre<rgba8, order_rgb> blender_rgb24_pre;
858 typedef blender_rgb_pre<rgba8, order_bgr> blender_bgr24_pre;
859 typedef blender_rgb_pre<srgba8, order_rgb> blender_srgb24_pre;
860 typedef blender_rgb_pre<srgba8, order_bgr> blender_sbgr24_pre;
861 typedef blender_rgb_pre<rgba16, order_rgb> blender_rgb48_pre;
862 typedef blender_rgb_pre<rgba16, order_bgr> blender_bgr48_pre;
863 typedef blender_rgb_pre<rgba32, order_rgb> blender_rgb96_pre;
864 typedef blender_rgb_pre<rgba32, order_bgr> blender_bgr96_pre;
865
866 typedef pixfmt_alpha_blend_rgb<blender_rgb24, rendering_buffer, 3> pixfmt_rgb24;
867 typedef pixfmt_alpha_blend_rgb<blender_bgr24, rendering_buffer, 3> pixfmt_bgr24;
868 typedef pixfmt_alpha_blend_rgb<blender_srgb24, rendering_buffer, 3> pixfmt_srgb24;
869 typedef pixfmt_alpha_blend_rgb<blender_sbgr24, rendering_buffer, 3> pixfmt_sbgr24;
870 typedef pixfmt_alpha_blend_rgb<blender_rgb48, rendering_buffer, 3> pixfmt_rgb48;
871 typedef pixfmt_alpha_blend_rgb<blender_bgr48, rendering_buffer, 3> pixfmt_bgr48;
872 typedef pixfmt_alpha_blend_rgb<blender_rgb96, rendering_buffer, 3> pixfmt_rgb96;
873 typedef pixfmt_alpha_blend_rgb<blender_bgr96, rendering_buffer, 3> pixfmt_bgr96;
874
875 typedef pixfmt_alpha_blend_rgb<blender_rgb24_pre, rendering_buffer, 3> pixfmt_rgb24_pre;
876 typedef pixfmt_alpha_blend_rgb<blender_bgr24_pre, rendering_buffer, 3> pixfmt_bgr24_pre;
877 typedef pixfmt_alpha_blend_rgb<blender_srgb24_pre, rendering_buffer, 3> pixfmt_srgb24_pre;
878 typedef pixfmt_alpha_blend_rgb<blender_sbgr24_pre, rendering_buffer, 3> pixfmt_sbgr24_pre;
879 typedef pixfmt_alpha_blend_rgb<blender_rgb48_pre, rendering_buffer, 3> pixfmt_rgb48_pre;
880 typedef pixfmt_alpha_blend_rgb<blender_bgr48_pre, rendering_buffer, 3> pixfmt_bgr48_pre;
881 typedef pixfmt_alpha_blend_rgb<blender_rgb96_pre, rendering_buffer, 3> pixfmt_rgb96_pre;
882 typedef pixfmt_alpha_blend_rgb<blender_bgr96_pre, rendering_buffer, 3> pixfmt_bgr96_pre;
883
884 typedef pixfmt_alpha_blend_rgb<blender_rgb24, rendering_buffer, 4, 0> pixfmt_rgbx32;
885 typedef pixfmt_alpha_blend_rgb<blender_rgb24, rendering_buffer, 4, 1> pixfmt_xrgb32;
886 typedef pixfmt_alpha_blend_rgb<blender_bgr24, rendering_buffer, 4, 1> pixfmt_xbgr32;
887 typedef pixfmt_alpha_blend_rgb<blender_bgr24, rendering_buffer, 4, 0> pixfmt_bgrx32;
888 typedef pixfmt_alpha_blend_rgb<blender_srgb24, rendering_buffer, 4, 0> pixfmt_srgbx32;
889 typedef pixfmt_alpha_blend_rgb<blender_srgb24, rendering_buffer, 4, 1> pixfmt_sxrgb32;
890 typedef pixfmt_alpha_blend_rgb<blender_sbgr24, rendering_buffer, 4, 1> pixfmt_sxbgr32;
891 typedef pixfmt_alpha_blend_rgb<blender_sbgr24, rendering_buffer, 4, 0> pixfmt_sbgrx32;
892 typedef pixfmt_alpha_blend_rgb<blender_rgb48, rendering_buffer, 4, 0> pixfmt_rgbx64;
893 typedef pixfmt_alpha_blend_rgb<blender_rgb48, rendering_buffer, 4, 1> pixfmt_xrgb64;
894 typedef pixfmt_alpha_blend_rgb<blender_bgr48, rendering_buffer, 4, 1> pixfmt_xbgr64;
895 typedef pixfmt_alpha_blend_rgb<blender_bgr48, rendering_buffer, 4, 0> pixfmt_bgrx64;
896 typedef pixfmt_alpha_blend_rgb<blender_rgb96, rendering_buffer, 4, 0> pixfmt_rgbx128;
897 typedef pixfmt_alpha_blend_rgb<blender_rgb96, rendering_buffer, 4, 1> pixfmt_xrgb128;
898 typedef pixfmt_alpha_blend_rgb<blender_bgr96, rendering_buffer, 4, 1> pixfmt_xbgr128;
899 typedef pixfmt_alpha_blend_rgb<blender_bgr96, rendering_buffer, 4, 0> pixfmt_bgrx128;
900
901 typedef pixfmt_alpha_blend_rgb<blender_rgb24_pre, rendering_buffer, 4, 0> pixfmt_rgbx32_pre;
902 typedef pixfmt_alpha_blend_rgb<blender_rgb24_pre, rendering_buffer, 4, 1> pixfmt_xrgb32_pre;
903 typedef pixfmt_alpha_blend_rgb<blender_bgr24_pre, rendering_buffer, 4, 1> pixfmt_xbgr32_pre;
904 typedef pixfmt_alpha_blend_rgb<blender_bgr24_pre, rendering_buffer, 4, 0> pixfmt_bgrx32_pre;
905 typedef pixfmt_alpha_blend_rgb<blender_srgb24_pre, rendering_buffer, 4, 0> pixfmt_srgbx32_pre;
906 typedef pixfmt_alpha_blend_rgb<blender_srgb24_pre, rendering_buffer, 4, 1> pixfmt_sxrgb32_pre;
907 typedef pixfmt_alpha_blend_rgb<blender_sbgr24_pre, rendering_buffer, 4, 1> pixfmt_sxbgr32_pre;
908 typedef pixfmt_alpha_blend_rgb<blender_sbgr24_pre, rendering_buffer, 4, 0> pixfmt_sbgrx32_pre;
909 typedef pixfmt_alpha_blend_rgb<blender_rgb48_pre, rendering_buffer, 4, 0> pixfmt_rgbx64_pre;
910 typedef pixfmt_alpha_blend_rgb<blender_rgb48_pre, rendering_buffer, 4, 1> pixfmt_xrgb64_pre;
911 typedef pixfmt_alpha_blend_rgb<blender_bgr48_pre, rendering_buffer, 4, 1> pixfmt_xbgr64_pre;
912 typedef pixfmt_alpha_blend_rgb<blender_bgr48_pre, rendering_buffer, 4, 0> pixfmt_bgrx64_pre;
913 typedef pixfmt_alpha_blend_rgb<blender_rgb96_pre, rendering_buffer, 4, 0> pixfmt_rgbx128_pre;
914 typedef pixfmt_alpha_blend_rgb<blender_rgb96_pre, rendering_buffer, 4, 1> pixfmt_xrgb128_pre;
915 typedef pixfmt_alpha_blend_rgb<blender_bgr96_pre, rendering_buffer, 4, 1> pixfmt_xbgr128_pre;
916 typedef pixfmt_alpha_blend_rgb<blender_bgr96_pre, rendering_buffer, 4, 0> pixfmt_bgrx128_pre;
917
918
919 //-----------------------------------------------------pixfmt_rgb24_gamma
920 template<class Gamma> class pixfmt_rgb24_gamma :
921 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer, 3>
922 {
923 public:
924 pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) :
925 pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_rgb, Gamma>, rendering_buffer, 3>(rb)
926 {
927 this->blender().gamma(g);
928 }
929 };
930
931 //-----------------------------------------------------pixfmt_srgb24_gamma
932 template<class Gamma> class pixfmt_srgb24_gamma :
933 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<srgba8, order_rgb, Gamma>, rendering_buffer, 3>
934 {
935 public:
936 pixfmt_srgb24_gamma(rendering_buffer& rb, const Gamma& g) :
937 pixfmt_alpha_blend_rgb<blender_rgb_gamma<srgba8, order_rgb, Gamma>, rendering_buffer, 3>(rb)
938 {
939 this->blender().gamma(g);
940 }
941 };
942
943 //-----------------------------------------------------pixfmt_bgr24_gamma
944 template<class Gamma> class pixfmt_bgr24_gamma :
945 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer, 3>
946 {
947 public:
948 pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) :
949 pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba8, order_bgr, Gamma>, rendering_buffer, 3>(rb)
950 {
951 this->blender().gamma(g);
952 }
953 };
954
955 //-----------------------------------------------------pixfmt_sbgr24_gamma
956 template<class Gamma> class pixfmt_sbgr24_gamma :
957 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<srgba8, order_bgr, Gamma>, rendering_buffer, 3>
958 {
959 public:
960 pixfmt_sbgr24_gamma(rendering_buffer& rb, const Gamma& g) :
961 pixfmt_alpha_blend_rgb<blender_rgb_gamma<srgba8, order_bgr, Gamma>, rendering_buffer, 3>(rb)
962 {
963 this->blender().gamma(g);
964 }
965 };
966
967 //-----------------------------------------------------pixfmt_rgb48_gamma
968 template<class Gamma> class pixfmt_rgb48_gamma :
969 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer, 3>
970 {
971 public:
972 pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) :
973 pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_rgb, Gamma>, rendering_buffer, 3>(rb)
974 {
975 this->blender().gamma(g);
976 }
977 };
978
979 //-----------------------------------------------------pixfmt_bgr48_gamma
980 template<class Gamma> class pixfmt_bgr48_gamma :
981 public pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer, 3>
982 {
983 public:
984 pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) :
985 pixfmt_alpha_blend_rgb<blender_rgb_gamma<rgba16, order_bgr, Gamma>, rendering_buffer, 3>(rb)
986 {
987 this->blender().gamma(g);
988 }
989 };
990
991 }
992
993 #endif
994