-Use PCI hidd stubs for reading/writing config memory
[AROS.git] / rom / hidds / graphics / BM_Class.c
blob6fdeb779c1ad86ee000889b8511c81d1e12af5d9
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics bitmap class implementation.
6 Lang: english
7 */
9 /****************************************************************************************/
11 #include <string.h>
12 #include <stdlib.h>
14 #include <proto/exec.h>
15 #include <proto/utility.h>
16 #include <proto/oop.h>
18 #include <exec/memory.h>
19 #include <utility/tagitem.h>
20 #include <oop/oop.h>
21 #include <oop/static_mid.h>
22 #include <graphics/text.h>
23 #include <graphics/scale.h>
25 #include <hidd/graphics.h>
27 #include "graphics_intern.h"
29 #undef SDEBUG
30 #undef DEBUG
31 #define SDEBUG 0
32 #define DEBUG 0
33 #include <aros/debug.h>
35 /****************************************************************************************/
37 #define POINT_OUTSIDE_CLIP(gc, x, y) \
38 ( (x) < GC_CLIPX1(gc) \
39 || (x) > GC_CLIPX2(gc) \
40 || (y) < GC_CLIPY1(gc) \
41 || (y) > GC_CLIPY2(gc) )
43 /*****************************************************************************************
45 NAME
46 --background_bitmap--
48 LOCATION
49 hidd.graphics.bitmap
51 NOTES
52 Every display driver should implement at least one bitmap class for displayable
53 bitmaps.
55 Normally this class doesn't need to have public ID. In order to use it the driver
56 should pass class pointer as aoHidd_BitMap_ClassPtr value to the graphics base class
57 in its moHidd_Gfx_NewBitMap implementation.
59 BitMap base class is in C++ terminology a pure virtual
60 baseclass. It will not allocate any bitmap data at all;
61 that is up to the subclass to do.
63 The main task of the BitMap baseclass is to store some information about the bitmap
64 like its size and pixelformat. A pixelformat is an object of private class which
65 stores the actual information about the format.
67 There are two ways that we can find out the pixfmt in our moHidd_Gfx_NewBitMap
68 implementation:
70 Displayable bitmap -
71 The tags will contain a modeid.
72 One can use this modeid to get a pointer to an
73 already registered pixfmt.
75 Non-displayable bitmap -
76 The aoHidd_BitMap_StdPixFmt or aoHidd_BitMap_Friend attribute will always be
77 passed.
79 *****************************************************************************************/
81 #define GOT_BM_ATTR(code) GOT_ATTR(code, aoHidd_BitMap, bitmap)
82 #define AO(x) aoHidd_BitMap_ ## x
84 #define BMAF(x) (1L << aoHidd_BitMap_ ## x)
86 #define BM_NONDISP_AF ( BMAF(Width) | BMAF(Height) | BMAF(PixFmt) )
89 #define PIXBUFBYTES (50000*4)
91 #define PIXBUF_DECLARE_VARS \
92 LONG __buflines; \
93 LONG __bufy = 0; \
94 LONG __worky = 0; \
95 LONG __height;
97 #define PIXBUF_ALLOC(buf,bytesperline,height) \
98 __height = height; \
99 __buflines = PIXBUFBYTES / (bytesperline); \
100 if (__buflines == 0) \
102 __buflines = 1; \
104 else if (__buflines > __height) \
106 __buflines = __height; \
108 buf = AllocVec((bytesperline) * __buflines, MEMF_PUBLIC); \
109 if (!buf && (__buflines > 1)) \
111 __buflines = 1; \
112 buf = AllocVec((bytesperline), MEMF_PUBLIC); \
115 #define PIXBUF_TIME_TO_START_PROCESS (__bufy == __worky)
117 #define PIXBUF_LINES_TO_PROCESS (((__height - __bufy) > __buflines) ? \
118 __buflines : __height - __bufy )
120 #define PIXBUF_TIME_TO_END_PROCESS (((__worky - __bufy + 1) == __buflines) || \
121 (__worky == __height - 1))
123 #define PIXBUF_NEXT_LINE \
124 __worky++; \
125 if ((__worky - __bufy) == __buflines) __bufy = __worky;
128 #define PIXBUF_FREE(buf) \
129 if (buf) FreeVec(buf);
131 /*****************************************************************************************
133 NAME
134 aoHidd_BitMap_Width
136 SYNOPSIS
137 [ISG], ULONG
139 LOCATION
140 hidd.graphics.bitmap
142 FUNCTION
143 Specifies bitmap width in pixels.
145 Setting this attribute does not cause actual bitmap resize, just updates the information
146 about it. Use this only from within subclasses only if you know what you do. For example
147 SDL hosted driver sets it when framebufer changes the resolution.
149 NOTES
151 EXAMPLE
153 BUGS
155 SEE ALSO
156 aoHidd_BitMap_Height
158 INTERNALS
160 *****************************************************************************************/
162 /*****************************************************************************************
164 NAME
165 aoHidd_BitMap_Height
167 SYNOPSIS
168 [ISG], ULONG
170 LOCATION
171 hidd.graphics.bitmap
173 FUNCTION
174 Specifies bitmap height in pixels.
176 Setting this attribute does not cause actual bitmap resize, just updates the information
177 about it. Use this only from within subclasses only if you know what you do. For example
178 SDL hosted driver sets it when framebufer changes the resolution.
180 NOTES
182 EXAMPLE
184 BUGS
186 SEE ALSO
187 aoHidd_BitMap_Width
189 INTERNALS
191 *****************************************************************************************/
193 /*****************************************************************************************
195 NAME
196 aoHidd_BitMap_Displayable
198 SYNOPSIS
199 [I.G], BOOL
201 LOCATION
202 hidd.graphics.bitmap
204 FUNCTION
205 The bitmap is displayable. A displayable bitmap is always managed by a display
206 driver and must have valid display mode ID specification.
208 If this attribute is not supplied during bitmap creation, its value defaults
209 to FALSE.
211 NOTES
213 EXAMPLE
215 BUGS
217 SEE ALSO
218 aoHidd_BitMap_ModeID
220 INTERNALS
222 *****************************************************************************************/
224 /*****************************************************************************************
226 NAME
227 aoHidd_BitMap_Visible
229 SYNOPSIS
230 [..G], BOOL
232 LOCATION
233 hidd.graphics.bitmap
235 FUNCTION
236 Check if the bitmap is currently visible on screen
238 NOTES
240 EXAMPLE
242 BUGS
243 Not all display drivers implement this attribute. No AROS components currently rely
244 on its value.
246 SEE ALSO
248 INTERNALS
249 Some drivers may choose to have this attribute internally setable. Do not rely on it
250 in any way and do not attempt to set it manually from within applications, this will
251 not do any nice things.
253 *****************************************************************************************/
255 /*****************************************************************************************
257 NAME
258 aoHidd_BitMap_IsLinearMem
260 SYNOPSIS
261 [..G], BOOL
263 LOCATION
264 hidd.graphics.bitmap
266 FUNCTION
267 Check if the bitmap provides linear memory access. This means that bitmap's
268 pixelbuffer is directly addressable by the CPU.
270 Bitmaps with no linear memory may implement moHidd_BitMap_ObtainDirectAccess,
271 but this means that this method will rely on mirrored buffer. In such a case
272 the user must call moHidd_BitMap_UpdateRect after modifying bitmap's contents.
274 NOTES
275 Used by cybergraphics.library/GetCyberMapAttr() for providing CYBRMATTR_ISLINEARMEM
276 value.
278 EXAMPLE
280 BUGS
281 Currently no display drivers implement this attribute despite many native mode
282 drivers actually provide linear memory.
284 SEE ALSO
285 moHidd_BitMap_ObtainDirectAccess, moHidd_BitMap_ReleaseDirectAccess,
286 moHidd_BitMap_UpdateRect
288 INTERNALS
290 *****************************************************************************************/
292 /*****************************************************************************************
294 NAME
295 aoHidd_BitMap_BytesPerRow
297 SYNOPSIS
298 [..G], ULONG
300 LOCATION
301 hidd.graphics.bitmap
303 FUNCTION
304 Query number of bytes per row in the bitmap storage buffer
306 NOTES
307 The returned value includes possible padding needed for alignment.
309 EXAMPLE
311 BUGS
313 SEE ALSO
315 INTERNALS
317 *****************************************************************************************/
319 /*****************************************************************************************
321 NAME
322 aoHidd_BitMap_ColorMap
324 SYNOPSIS
325 [..G], OOP_Object *
327 LOCATION
328 hidd.graphics.bitmap
330 FUNCTION
331 Return associated colormap (palette) object.
333 By default only displayable bitmaps have colormaps. However a colormap can be attached
334 to any bitmap using moHidd_BitMap_SetColors or moHidd_BitMap_SetColorMap.
336 Note that manual attaching of a colormap to a nondisplayable bitmap may cause undesired
337 side-effects on graphics.library behavior. It's better not to do this at all. The system
338 knows what it does better than you.
340 NOTES
342 EXAMPLE
344 BUGS
346 SEE ALSO
347 moHidd_BitMap_SetColorMap, moHidd_BitMap_SetColors.
349 INTERNALS
351 *****************************************************************************************/
353 /*****************************************************************************************
355 NAME
356 aoHidd_BitMap_Friend
358 SYNOPSIS
359 [I.G], OOP_Object *
361 LOCATION
362 hidd.graphics.bitmap
364 FUNCTION
365 Specify a friend bitmap. The bitmap will be allocated so that it
366 is optimized for blitting to this bitmap.
368 Display drivers may query this attribute and then query friend bitmap
369 for anything they want (like pixelformat, mode ID, etc).
371 Note that explicit specification of mode ID and/or standard pixelformat
372 should override defaults provided by friend bitmap (i.e. actually breaking
373 the friendship).
375 NOTES
377 EXAMPLE
379 BUGS
381 SEE ALSO
383 INTERNALS
385 *****************************************************************************************/
387 /*****************************************************************************************
389 NAME
390 aoHidd_BitMap_GfxHidd
392 SYNOPSIS
393 [I.G], OOP_Object *
395 LOCATION
396 hidd.graphics.bitmap
398 FUNCTION
399 Specify display driver object this bitmap was created with.
401 Normally the user doesn't have to supply this attribute. Instead you should use
402 driver's moHidd_Gfx_NewBitMap method in order to create bitmaps. In this case
403 aoHidd_BitMap_GfxHidd attribute will be provided by graphics driver base class
404 with the correct value.
406 It is illegal to manually create bitmap objects with no driver associated.
407 graphics.library maintains at least a memory driver for nondisplayable
408 bitmaps in system RAM without any acceleration.
410 NOTES
412 EXAMPLE
414 BUGS
416 SEE ALSO
417 CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap
419 INTERNALS
421 *****************************************************************************************/
423 /*****************************************************************************************
425 NAME
426 aoHidd_BitMap_StdPixFmt
428 SYNOPSIS
429 [I..], HIDDT_StdPixFmt
431 LOCATION
432 hidd.graphics.bitmap
434 FUNCTION
435 Specify standard pixelformat code (one of vHidd_StdPixFmt_... values) for the
436 bitmap.
438 Values less than num_Hidd_PseudoStdPixFmt are illegal for this attribute.
440 Actually the bitmap class itself ignores this attribute. It is processed by
441 CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap method in order to look up a corresponding
442 pixelformat object in the system's database.
444 NOTES
445 Bitmaps with this attribute set should be created as RAM bitmaps with direct CPU
446 access. It is not recommended to replace them with, for example, virtual surfaces on
447 hosted AROS. Such bitmaps are expected to be directly addressable and breaking
448 this may cause undesired side effects.
450 EXAMPLE
452 BUGS
454 SEE ALSO
455 aoHidd_BitMap_PixFmt, CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap
457 INTERNALS
458 Currently all display drivers omit specifying own bitmap class for bitmaps with this
459 attribute set, letting base class (actually memory driver) to select an appropriate
460 class for it. This way it ends up in a bitmap of CLID_Hidd_ChunkyBM or CLID_Hidd_PlanarBM
461 class. It is recommended to follow this rule. It's not prohibited, however, to do some
462 adjustments to the bitmap (like alignment) in order to optimize blitting to/from it.
463 In fact if the display driver was asked to create such a bitmap, this means that
464 the standard bitmap is being created as a friend of some bitmap which was allocated
465 using this driver. This way the bitmap is expected to be friendly to this driver.
467 *****************************************************************************************/
469 /*****************************************************************************************
471 NAME
472 aoHidd_BitMap_PixFmt
474 SYNOPSIS
475 [I.G], OOP_Object *
477 LOCATION
478 hidd.graphics.bitmap
480 FUNCTION
481 Returns pixelformat descriptor object associated with the bitmap.
483 Every bitmap has some associated pixelformat object. Pixelformat objects are
484 shared data storages, so many bitmaps may refer to the same pixelformat objects.
486 NOTES
488 EXAMPLE
490 BUGS
492 SEE ALSO
494 INTERNALS
496 *****************************************************************************************/
498 /*****************************************************************************************
500 NAME
501 aoHidd_BitMap_ModeID
503 SYNOPSIS
504 [I.G], HIDDT_ModeID
506 LOCATION
507 hidd.graphics.bitmap
509 FUNCTION
510 Specify display mode ID for displayable bitmap.
512 A displayable bitmap must have this attribute supplied with valid value. A nondisplayable
513 one may miss it, however it may remember it if it was created as a friend of displayable
514 one. This way you may create another displayable bitmap as a friend of nondisplayable
515 one which in turn is a friend of displayable one.
517 NOTES
519 EXAMPLE
521 BUGS
523 SEE ALSO
525 INTERNALS
527 *****************************************************************************************/
529 /*****************************************************************************************
531 NAME
532 aoHidd_BitMap_ClassPtr
534 SYNOPSIS
535 [I.G], OOP_Class *
537 LOCATION
538 hidd.graphics.bitmap
540 FUNCTION
541 Explicitly specify bitmap's class pointer.
543 This attribute is simply remembered by bitmap base class. Its main purpose is to let
544 graphics driver base class to select a class on which to call OOP_NewObject() in
545 its moHidd_Gfx_NewBitMap implementation.
547 If neither this attribute nor aoHidd_BitMap_ClassID attribute is provided for
548 moHidd_Gfx_NewBitMap, graphics base class will do its best in order to find out the
549 correct class based on aoHidd_StdPixFmt attribute value or aoHidd_BitMap_ClassPtr value
550 of friend bitmap.
552 NOTES
554 EXAMPLE
556 BUGS
558 SEE ALSO
559 aoHidd_BitMap_ClassID, CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap
561 INTERNALS
563 *****************************************************************************************/
565 /*****************************************************************************************
567 NAME
568 aoHidd_BitMap_ClassID
570 SYNOPSIS
571 [I..]
573 LOCATION
574 hidd.graphics.bitmap
576 FUNCTION
577 Explicitly specify bitmap's class ID.
579 The purpose of this attribute is to let graphics driver base class to select a class
580 on which to call OOP_NewObject() in its moHidd_Gfx_NewBitMap implementation.
582 If neither this attribute nor aoHidd_BitMap_ClassPtr attribute is provided for
583 moHidd_Gfx_NewBitMap, graphics base class will do its best in order to find out the
584 correct class based on aoHidd_StdPixFmt attribute value or aoHidd_BitMap_ClassPtr value
585 of friend bitmap.
587 NOTES
589 EXAMPLE
591 BUGS
592 The pointer to a given class will not be remembered as aoHidd_BitMap_ClassPtr value.
594 SEE ALSO
595 aoHidd_BitMap_ClassPtr, CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap
597 INTERNALS
599 *****************************************************************************************/
601 /*****************************************************************************************
603 NAME
604 aoHidd_BitMap_PixFmtTags
606 SYNOPSIS
607 [I..]
609 LOCATION
610 hidd.graphics.bitmap
612 FUNCTION
613 Only used by subclasses of BitMap class.
615 NOTES
617 EXAMPLE
619 BUGS
621 SEE ALSO
623 INTERNALS
625 *****************************************************************************************/
627 /*****************************************************************************************
629 NAME
630 aoHidd_BitMap_FrameBuffer
632 SYNOPSIS
633 [I..], BOOL
635 LOCATION
636 hidd.graphics.bitmap
638 FUNCTION
639 Specifies that the bitmap is a framebuffer bitmap.
641 A detailed description of a framebuffer is given in CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap
642 and in CLID_Hidd_Gfx/moHidd_Gfx_Show documentation.
644 Specifying this attribute to moHidd_Gfx_NewBitMap method causes also implicit setting
645 of aoHidd_BitMap_Displayable to TRUE.
647 NOTES
649 EXAMPLE
651 BUGS
653 SEE ALSO
655 INTERNALS
657 *****************************************************************************************/
659 /*****************************************************************************************
661 NAME
662 aoHidd_BitMap_LeftEdge
664 SYNOPSIS
665 [.SG]
667 LOCATION
668 hidd.graphics.bitmap
670 FUNCTION
671 Controls horizontal position of a scrollable screen bitmap.
673 Size of displayable bitmaps may differ from actual screen size. In this case the
674 bitmap can be scrolled around the whole display area. If the bitmap is larger than
675 the display, only its part can be visible.
677 Setting this attribute causes changing left origin point of the bitmap. The value
678 of this attribute represents an offset from the physical edge of the display to the
679 logical edge of the bitmap. This means that if a large bitmap scrolls to the left in
680 order to reveal its right part, the offset will be negative. If the bitmap scrolls
681 to the left (possibly revealing another bitmap behind it), the offset will be positive.
683 It's up to the display driver to set scroll limits. If the value of the attribute
684 becomes unacceptable for any reason, the driver should adjust it and provide the real
685 resulting value back.
687 NOTES
688 Implementing screen scrolling does not enforce to implement screen composition, despite
689 the composition is really based on scrolling (in case of composition scrolling a bitmap
690 off-display is expected to reveal another bitmap behing it instead of empty space).
692 EXAMPLE
694 BUGS
696 SEE ALSO
697 aoHidd_BitMap_TopEdge
699 INTERNALS
700 Base class will always provide zero value for this attribute and ignore all attempts
701 to set it. This means that by default bitmaps don't scroll and this needs explicit
702 implementation in the display driver.
704 *****************************************************************************************/
706 /*****************************************************************************************
708 NAME
709 aoHidd_BitMap_TopEdge
711 SYNOPSIS
712 [.SG]
714 LOCATION
715 hidd.graphics.bitmap
717 FUNCTION
718 Controls vertical position of a scrollable screen bitmap.
720 Size of displayable bitmaps may differ from actual screen size. In this case the
721 bitmap can be scrolled around the whole display area. If the bitmap is larger than
722 the display, only its part can be visible.
724 Setting this attribute causes changing top origin point of the bitmap. The value
725 of this attribute represents an offset from the physical edge of the display to the
726 logical edge of the bitmap. This means that if a large bitmap scrolls upwards in
727 order to reveal its bottom part, the offset will be negative. If the bitmap scrolls
728 downdards (possibly revealing another bitmap behind it), the offset will be positive.
730 It's up to the display driver to set scroll limits. If the value of the attribute
731 becomes unacceptable for any reason, the driver should adjust it and provide the real
732 resulting value back.
734 NOTES
735 Implementing screen scrolling does not enforce to implement screen composition, despite
736 the composition is really based on scrolling (in case of composition scrolling a bitmap
737 off-display is expected to reveal another bitmap behing it instead of empty space).
739 EXAMPLE
741 BUGS
743 SEE ALSO
745 INTERNALS
747 *****************************************************************************************/
749 /*****************************************************************************************
751 NAME
752 aoHidd_BitMap_Align
754 SYNOPSIS
755 [I..]
757 LOCATION
758 hidd.graphics.bitmap
760 FUNCTION
761 Specify number of pixels to align bitmap data width to.
763 This attribute can be added in CLID_Hidd_Gfx/moHidd_Gfx_NewBitMap implementation
764 in order to enforce alignment needed for example by blitting hardware.
766 NOTES
768 EXAMPLE
770 BUGS
772 SEE ALSO
774 INTERNALS
776 *****************************************************************************************/
778 /****************************************************************************************/
780 OOP_Object *BM__Root__New(OOP_Class *cl, OOP_Object *obj, struct pRoot_New *msg)
782 EnterFunc(bug("BitMap::New()\n"));
784 obj = (OOP_Object *) OOP_DoSuperMethod(cl, obj, (OOP_Msg) msg);
786 if (NULL != obj)
788 struct TagItem colmap_tags[] =
790 { aHidd_ColorMap_NumEntries , 16 },
791 { TAG_DONE }
793 struct HIDDBitMapData *data;
794 BOOL ok = TRUE;
796 DECLARE_ATTRCHECK(bitmap);
797 IPTR attrs[num_Total_BitMap_Attrs] = {0};
799 data = OOP_INST_DATA(cl, obj);
801 /* clear all data and set some default values */
802 memset(data, 0, sizeof(struct HIDDBitMapData));
804 attrs[AO(Align)] = 16;
806 data->width = 320;
807 data->height = 200;
808 data->reqdepth = 8;
809 data->displayable = FALSE;
810 data->pf_registered = FALSE;
811 data->modeid = vHidd_ModeID_Invalid;
813 if (0 != OOP_ParseAttrs(msg->attrList, attrs, num_Total_BitMap_Attrs,
814 &ATTRCHECK(bitmap), HiddBitMapAttrBase))
816 D(bug("!!! ERROR PARSING ATTRS IN BitMap::New() !!!\n"));
817 D(bug("!!! NUMBER OF ATTRS IN IF: %d !!!\n", num_Total_BitMap_Attrs));
818 ok = FALSE;
821 if (ok)
823 if (!GOT_BM_ATTR(GfxHidd))
825 D(bug("!!!! BM CLASS DID NOT GET GFX HIDD !!!\n"));
826 D(bug("!!!! The reason for this is that the gfxhidd subclass NewBitmap() method\n"));
827 D(bug("!!!! has not left it to the baseclass to actually create the object,\n"));
828 D(bug("!!!! but rather done it itself. This MUST be corrected in the gfxhidd subclass\n"));
829 D(bug("!!!! ATTRCHECK: %p !!!!\n", ATTRCHECK(bitmap)));
831 ok = FALSE;
833 else
835 data->gfxhidd = (OOP_Object *)attrs[AO(GfxHidd)];
839 /* Save pointer to friend bitmap */
840 if (GOT_BM_ATTR(Friend))
841 data->friend = (OOP_Object *)attrs[AO(Friend)];
843 if (ok)
845 if ( attrs[AO(Displayable)] )
847 /* We should allways get modeid, but we check anyway */
848 if (!GOT_BM_ATTR(ModeID))
850 D(bug("!!! BitMap:New() DID NOT GET MODEID FOR DISPLAYABLE BITMAP !!!\n"));
851 ok = FALSE;
853 else
855 HIDDT_ModeID modeid;
856 OOP_Object *sync, *pf;
858 modeid = (HIDDT_ModeID)attrs[AO(ModeID)];
860 if (!HIDD_Gfx_GetMode(data->gfxhidd, modeid, &sync, &pf))
862 D(bug("!!! BitMap::New() RECEIVED INVALID MODEID %p\n", modeid));
863 ok = FALSE;
865 else
867 IPTR width, height;
869 /* Update the bitmap with data from the modeid */
870 OOP_GetAttr(sync, aHidd_Sync_HDisp, &width);
871 OOP_GetAttr(sync, aHidd_Sync_VDisp, &height);
873 data->width = width;
874 data->height = height;
875 data->displayable = TRUE;
877 /* The PixFmt is allready registered and locked in the PixFmt database */
878 data->prot.pixfmt = pf;
882 else
883 { /* displayable */
884 if (BM_NONDISP_AF != (BM_NONDISP_AF & ATTRCHECK(bitmap)))
887 * One of Width, Height and PixFmt is not set.
888 * This is either a mailformed call, or empty planar BitMap object
889 * for late initialization.
890 * In the latter case we'll specify aHidd_PlanarBM_AllocPlanes, FALSE.
892 BOOL planes_alloced = GetTagData(aHidd_PlanarBM_AllocPlanes, TRUE, msg->attrList);
894 if (planes_alloced)
896 D(bug("!!! BitMap:New(): NO PIXFMT FOR NONDISPLAYABLE BITMAP !!!\n"));
897 ok = FALSE;
900 else
902 data->prot.pixfmt = (OOP_Object *)attrs[AO(PixFmt)];
904 } /* displayable */
906 if (GOT_BM_ATTR(Width))
907 data->width = attrs[AO(Width)];
908 if (GOT_BM_ATTR(Height))
909 data->height = attrs[AO(Height)];
910 if (GOT_BM_ATTR(Depth))
911 data->reqdepth = attrs[AO(Depth)];
912 } /* if (ok) */
914 if (ok)
917 * Calculate suggested bytes per row value based on requested alignment and
918 * pixelformat's bytes per pixel value.
919 * PixFmt will be NULL in case of late initialization.
921 if (data->prot.pixfmt)
923 ULONG align = attrs[AO(Align)] - 1;
924 ULONG width = (data->width + align) & ~align;
925 IPTR bytesperpixel, stdpf;
927 OOP_GetAttr(data->prot.pixfmt, aHidd_PixFmt_BytesPerPixel, &bytesperpixel);
928 OOP_GetAttr(data->prot.pixfmt, aHidd_PixFmt_StdPixFmt, &stdpf);
930 if (stdpf == vHidd_StdPixFmt_Plane)
933 * Planar format actually have 8 pixels per one byte.
934 * However bytesperpixel == 1 for them. Perhaps this should
935 * be changed to 0 ?
937 data->bytesPerRow = width >> 3;
939 else
941 data->bytesPerRow = width * bytesperpixel;
945 /* initialize the direct method calling */
947 if (GOT_BM_ATTR(ModeID))
948 data->modeid = attrs[AO(ModeID)];
949 data->classptr = (OOP_Class *)attrs[AO(ClassPtr)];
951 #if USE_FAST_PUTPIXEL
952 data->putpixel = (IPTR (*)(OOP_Class *, OOP_Object *, struct pHidd_BitMap_PutPixel *))
953 OOP_GetMethod(obj, CSD(cl)->putpixel_mid);
954 if (NULL == data->putpixel)
955 ok = FALSE;
956 #endif
958 #if USE_FAST_GETPIXEL
959 data->getpixel = (IPTR (*)(OOP_Class *, OOP_Object *, struct pHidd_BitMap_GetPixel *))
960 OOP_GetMethod(obj, CSD(cl)->getpixel_mid);
961 if (NULL == data->getpixel)
962 ok = FALSE;
963 #endif
965 #if USE_FAST_DRAWPIXEL
966 data->drawpixel = (IPTR (*)(OOP_Class *, OOP_Object *, struct pHidd_BitMap_DrawPixel *))
967 OOP_GetMethod(obj, CSD(cl)->drawpixel_mid);
968 if (NULL == data->drawpixel)
969 ok = FALSE;
970 #endif
972 /* Try to create the colormap */
974 /* stegerg: Only add a ColorMap for a visible bitmap (screen). This
975 is important because one can create for example a bitmap
976 in PIXFMT_LUT8 without friend bitmap and then copy this
977 bitmap to a 16 bit screen. During copy the screen bitmap
978 CLUT must be used, which would not happen if our PIXFMT_LUT8
979 also had a colormap itself because then bltbitmap would use the
980 colormap of the PIXFMT_LUT8 bitmap as lookup, which in this
981 case would just cause everything to become black in the
982 destination (screen) bitmap, because noone ever sets up the
983 colormap of the PIXFMT_LUT8 bitmap */
985 if (data->displayable)
987 data->colmap = OOP_NewObject(NULL, CLID_Hidd_ColorMap, colmap_tags);
988 if (NULL == data->colmap)
989 ok = FALSE;
994 if (!ok)
996 ULONG dispose_mid;
998 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
1000 OOP_CoerceMethod(cl, obj, (OOP_Msg)&dispose_mid);
1002 obj = NULL;
1004 } /* if(obj) */
1006 } /* if (NULL != obj) */
1008 ReturnPtr("BitMap::New", OOP_Object *, obj);
1011 /****************************************************************************************/
1013 void BM__Root__Dispose(OOP_Class *cl, OOP_Object *obj, OOP_Msg *msg)
1015 struct HIDDBitMapData *data = OOP_INST_DATA(cl, obj);
1017 EnterFunc(bug("BitMap::Dispose()\n"));
1019 if (NULL != data->colmap)
1020 OOP_DisposeObject(data->colmap);
1022 D(bug("Calling super\n"));
1024 /* Release the previously registered pixel format */
1025 if (data->pf_registered)
1026 HIDD_Gfx_ReleasePixFmt(data->gfxhidd, data->prot.pixfmt);
1028 OOP_DoSuperMethod(cl, obj, (OOP_Msg) msg);
1030 ReturnVoid("BitMap::Dispose");
1033 /****************************************************************************************/
1035 VOID BM__Root__Get(OOP_Class *cl, OOP_Object *obj, struct pRoot_Get *msg)
1037 struct HIDDBitMapData *data = OOP_INST_DATA(cl, obj);
1038 ULONG idx;
1040 EnterFunc(bug("BitMap::Get() attrID: %i storage: %p\n", msg->attrID, msg->storage));
1042 if(IS_BITMAP_ATTR(msg->attrID, idx))
1044 switch(idx)
1046 case aoHidd_BitMap_Width:
1047 *msg->storage = data->width;
1048 D(bug(" width: %i\n", data->width));
1049 break;
1051 case aoHidd_BitMap_Height:
1052 *msg->storage = data->height;
1053 break;
1055 case aoHidd_BitMap_Depth:
1056 *msg->storage = data->reqdepth;
1057 break;
1059 case aoHidd_BitMap_Displayable:
1060 *msg->storage = (IPTR) data->displayable;
1061 break;
1063 case aoHidd_BitMap_PixFmt:
1064 *msg->storage = (IPTR)data->prot.pixfmt;
1065 break;
1067 case aoHidd_BitMap_Friend:
1068 *msg->storage = (IPTR)data->friend;
1069 break;
1071 case aoHidd_BitMap_ColorMap:
1072 *msg->storage = (IPTR)data->colmap;
1073 break;
1075 #if 0
1076 case aoHidd_BitMap_Depth:
1077 if (NULL != data->prot.pixfmt)
1079 *msg->storage = ((HIDDT_PixelFormat *)data->prot.pixfmt)->depth;
1081 else
1083 *msg->storage = data->reqdepth;
1085 break;
1087 #endif
1089 case aoHidd_BitMap_GfxHidd:
1090 *msg->storage = (IPTR)data->gfxhidd;
1091 break;
1093 case aoHidd_BitMap_ModeID:
1094 *msg->storage = data->modeid;
1095 break;
1097 case aoHidd_BitMap_BytesPerRow:
1098 *msg->storage = data->bytesPerRow;
1099 break;
1101 /* Generic bitmaps don't scroll. This has to be implemented
1102 in the subclass */
1103 case aoHidd_BitMap_LeftEdge:
1104 case aoHidd_BitMap_TopEdge:
1105 *msg->storage = 0;
1106 break;
1108 case aoHidd_BitMap_ClassPtr:
1109 *msg->storage = (IPTR)data->classptr;
1110 break;
1112 default:
1113 D(bug("UNKNOWN ATTR IN BITMAP BASECLASS: %d\n", idx));
1114 OOP_DoSuperMethod(cl, obj, (OOP_Msg) msg);
1115 break;
1118 else
1120 OOP_DoSuperMethod(cl, obj, (OOP_Msg) msg);
1123 ReturnVoid("BitMap::Get");
1126 /****************************************************************************************/
1128 #define UB(x) ((UBYTE *)x)
1130 /*****************************************************************************************
1132 NAME
1133 moHidd_BitMap_SetColors
1135 SYNOPSIS
1136 BOOL OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_SetColors *msg);
1138 BOOL HIDD_BM_SetColors (OOP_Object *obj, HIDDT_Color *colors,
1139 ULONG firstColor, ULONG numColors);
1141 LOCATION
1142 hidd.graphics.bitmap
1144 FUNCTION
1145 Sets values for one or more colors in the colormap object associated with the
1146 bitmap.
1148 The colormap will be created if it does not exist.
1150 Only ARGB values from the source array are taken into account. pixval member is
1151 updated with the real pixel value for every color.
1153 INPUTS
1154 obj - A bitmap object whose colormap needs to be set
1155 colors - A pointer to source data array
1156 firstColor - Number of the first color to set
1157 numColors - Number of subsequent colors to set
1159 RESULT
1160 TRUE on success, FALSE in case of some error (like out of memory)
1162 NOTES
1164 EXAMPLE
1166 BUGS
1168 SEE ALSO
1169 CLID_Hidd_ColorMap/moHidd_ColorMap_SetColors
1171 INTERNALS
1173 *****************************************************************************************/
1175 BOOL BM__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_SetColors *msg)
1177 /* Copy the colors into the internal buffer */
1178 struct HIDDBitMapData *data;
1180 data = OOP_INST_DATA(cl, o);
1182 /* Subclass has initialized HIDDT_Color->pixelVal field and such.
1183 Just copy it into the colortab.
1186 if (NULL == data->colmap)
1188 struct TagItem colmap_tags[] =
1190 { aHidd_ColorMap_NumEntries, 0 },
1191 { TAG_DONE }
1194 colmap_tags[0].ti_Data = msg->firstColor + msg->numColors;
1195 data->colmap = OOP_NewObject(NULL, CLID_Hidd_ColorMap, colmap_tags);
1198 if (NULL == data->colmap)
1200 return FALSE;
1203 /* Use the colormap class to set the colors */
1204 return HIDD_CM_SetColors(data->colmap, msg->colors,
1205 msg->firstColor, msg->numColors,
1206 data->prot.pixfmt);
1210 /*****************************************************************************************
1212 NAME
1213 moHidd_BitMap_DrawPixel
1215 SYNOPSIS
1216 ULONG OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawPixel *msg);
1218 ULONG HIDD_BM_DrawPixel(OOP_Object *obj, OOP_Object *gc, WORD x, WORD y);
1220 LOCATION
1221 hidd.graphics.bitmap
1223 FUNCTION
1224 Changes the pixel at (x,y). The color of the pixel depends on the
1225 attributes of gc, eg. colors, drawmode, colormask etc.
1226 This function does not check the coordinates.
1228 INPUTS
1229 obj - A bitmap to draw on
1230 gc - A GC (graphics context) object to use for drawing
1231 x, y - Coordinates of the pixel to draw
1233 RESULT
1234 Undefined. Many drivers declare this method as void.
1236 NOTES
1238 EXAMPLE
1240 BUGS
1242 SEE ALSO
1244 INTERNALS
1246 TODO
1247 - Support for shapeplane.
1248 - Optimize
1250 *****************************************************************************************/
1252 ULONG BM__Hidd_BitMap__DrawPixel(OOP_Class *cl, OOP_Object *obj,
1253 struct pHidd_BitMap_DrawPixel *msg)
1255 HIDDT_Pixel src, dest, val;
1256 HIDDT_DrawMode mode;
1257 HIDDT_Pixel writeMask;
1258 OOP_Object *gc;
1259 #if USE_FAST_PUTPIXEL
1260 struct pHidd_BitMap_PutPixel p;
1261 #endif
1263 /* EnterFunc(bug("BitMap::DrawPixel() x: %i, y: %i\n", msg->x, msg->y));
1266 Example: Pixels which bits are set to 0 in the colMask must be
1267 unchanged
1269 data->colMask = 001111
1270 dest = 101100
1273 writeMask = ~data->colMask & dest
1274 = 110000 & 101100
1275 = 100000
1277 dest = data->fg && dest = 010100
1280 dest = dest & (writeMask | data->ColMask)
1281 = 010100 & (100000 | 001111)
1282 = 010100 & (101111)
1283 = 000100
1286 dest = dest | writeMask;
1287 = 000100 100000
1288 = 100100
1292 gc = msg->gc;
1294 src = GC_FG(gc);
1295 mode = GC_DRMD(gc);
1297 #if OPTIMIZE_DRAWPIXEL_FOR_COPY
1298 if (vHidd_GC_DrawMode_Copy == mode && GC_COLMASK(gc) == ~0)
1300 val = src;
1302 else
1304 #endif
1306 dest = HIDD_BM_GetPixel(obj, msg->x, msg->y);
1307 writeMask = ~GC_COLMASK(gc) & dest;
1309 val = 0;
1311 if(mode & 1) val = ( src & dest);
1312 if(mode & 2) val = ( src & ~dest) | val;
1313 if(mode & 4) val = (~src & dest) | val;
1314 if(mode & 8) val = (~src & ~dest) | val;
1316 val = (val & (writeMask | GC_COLMASK(gc) )) | writeMask;
1318 #if OPTIMIZE_DRAWPIXEL_FOR_COPY
1320 #endif
1322 #if USE_FAST_PUTPIXEL
1323 p.mID = CSD(cl)->putpixel_mid;
1324 p.x = msg->x;
1325 p.y = msg->y;
1326 p.pixel = val;
1327 PUTPIXEL(obj, &p);
1328 #else
1330 HIDD_BM_PutPixel(obj, msg->x, msg->y, val);
1331 #endif
1333 /* ReturnInt("BitMap::DrawPixel ", ULONG, 1); */ /* in quickmode return always 1 */
1335 return 1;
1338 /*****************************************************************************************
1340 NAME
1341 moHidd_BitMap_DrawLine
1343 SYNOPSIS
1344 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawPixel *msg);
1346 VOID HIDD_BM_DrawLine(OOP_Object *obj, OOP_Object *gc, WORD x1, WORD y1,
1347 WORD x2, WORD y2);
1349 LOCATION
1350 hidd.graphics.bitmap
1352 FUNCTION
1353 Draws a line from (x1,y1) to (x2,y2) in the specified gc.
1354 The function does not clip the line against the drawing area.
1356 INPUTS
1357 obj - A bitmap to draw on
1358 gc - A graphics context object to use
1359 x1,y1 - start point of the line in pixels
1360 x2,y2 - end point of the line in pixels
1362 RESULT
1363 None.
1365 NOTES
1367 EXAMPLE
1369 BUGS
1371 SEE ALSO
1373 INTERNALS
1374 Uses midpoint line ("Bresenham") algorithm([FOL90] 3.2.2)
1376 TODO Support for line pattern
1377 Optimize remove if t == 1 ...
1378 Implement better clipping: Should be no reason to calculate
1379 more than the part of the line that is inside the cliprect
1381 *****************************************************************************************/
1383 VOID BM__Hidd_BitMap__DrawLine
1385 OOP_Class *cl, OOP_Object *obj, struct pHidd_BitMap_DrawLine *msg
1388 WORD dx, dy, incrE, incrNE, d, x, y, s1, s2, t, i;
1389 LONG x1, y1, x2, y2;
1390 UWORD maskLine; /* for line pattern */
1391 ULONG fg; /* foreground pen */
1392 BOOL doclip;
1393 BOOL opaque;
1394 OOP_Object *gc;
1397 /* bug("BitMap::DrawLine()\n");
1398 */ EnterFunc(bug("BitMap::DrawLine() x1: %i, y1: %i x2: %i, y2: %i\n", msg->x1, msg->y1, msg->x2, msg->y2));
1400 gc = msg->gc;
1401 doclip = GC_DOCLIP(gc);
1402 opaque = (GC_COLEXP(gc) & vHidd_GC_ColExp_Opaque) ? TRUE : FALSE;
1403 fg = GC_FG(gc);
1405 maskLine = 1 << GC_LINEPATCNT(gc);
1407 if (doclip)
1409 /* If line is not inside cliprect, then just return */
1410 /* Normalize coords */
1411 if (msg->x1 > msg->x2)
1413 x1 = msg->x2; x2 = msg->x1;
1415 else
1417 x1 = msg->x1; x2 = msg->x2;
1420 if (msg->y1 > msg->y2)
1422 y1 = msg->y2; y2 = msg->y1;
1424 else
1426 y1 = msg->y1; y2 = msg->y2;
1429 if ( x1 > GC_CLIPX2(gc)
1430 || x2 < GC_CLIPX1(gc)
1431 || y1 > GC_CLIPY2(gc)
1432 || y2 < GC_CLIPY1(gc) )
1435 /* Line is not inside cliprect, so just return */
1436 return;
1441 x1 = msg->x1;
1442 y1 = msg->y1;
1443 x2 = msg->x2;
1444 y2 = msg->y2;
1446 if (y1 == y2)
1449 Horizontal line drawing code.
1451 y = y1;
1453 /* Don't swap coordinates if x2 < x1! Because of linepattern! */
1455 if (x1 < x2)
1457 x2++;
1458 dx = 1;
1460 else
1462 x2--;
1463 dx = -1;
1466 for(i = x1; i != x2; i += dx)
1468 /* Pixel inside ? */
1470 if (!doclip || !POINT_OUTSIDE_CLIP(gc, i, y ))
1472 if(GC_LINEPAT(gc) & maskLine)
1474 HIDD_BM_DrawPixel(obj, gc, i, y);
1476 else if (opaque)
1478 GC_FG(gc) = GC_BG(gc);
1479 HIDD_BM_DrawPixel(obj, gc, i, y);
1480 GC_FG(gc) = fg;
1484 maskLine = maskLine >> 1;
1485 if (!maskLine) maskLine = 1L << 15;
1488 else if (x1 == x2)
1491 Vertical line drawing code.
1493 x = x1;
1495 /* Don't swap coordinates if y2 < y1! Because of linepattern! */
1497 if (y1 < y2)
1499 y2++;
1500 dy = 1;
1502 else
1504 y2--;
1505 dy = -1;
1508 for(i = y1; i != y2; i += dy)
1510 /* Pixel inside ? */
1511 if (!doclip || !POINT_OUTSIDE_CLIP(gc, x, i ))
1513 if(GC_LINEPAT(gc) & maskLine)
1515 HIDD_BM_DrawPixel(obj, gc, x, i);
1517 else if (opaque)
1519 GC_FG(gc) = GC_BG(gc);
1520 HIDD_BM_DrawPixel(obj, gc, x, i);
1521 GC_FG(gc) = fg;
1525 maskLine = maskLine >> 1;
1526 if (!maskLine) maskLine = 1L << 15;
1530 else
1533 Generic line drawing code.
1535 /* Calculate slope */
1536 dx = abs(x2 - x1);
1537 dy = abs(y2 - y1);
1539 /* which direction? */
1540 if((x2 - x1) > 0) s1 = 1; else s1 = - 1;
1541 if((y2 - y1) > 0) s2 = 1; else s2 = - 1;
1543 /* change axes if dx < dy */
1544 if(dx < dy)
1546 d = dx;
1547 dx = dy;
1548 dy = d;
1549 t = 0;
1551 else
1553 t = 1;
1556 d = 2 * dy - dx; /* initial value of d */
1558 incrE = 2 * dy; /* Increment use for move to E */
1559 incrNE = 2 * (dy - dx); /* Increment use for move to NE */
1561 x = x1; y = y1;
1563 for(i = 0; i <= dx; i++)
1565 /* Pixel inside ? */
1566 if (!doclip || !POINT_OUTSIDE_CLIP(gc, x, y ))
1568 if(GC_LINEPAT(gc) & maskLine)
1570 HIDD_BM_DrawPixel(obj, gc, x, y);
1572 else if (opaque)
1574 GC_FG(gc) = GC_BG(gc);
1575 HIDD_BM_DrawPixel(obj, gc, x, y);
1576 GC_FG(gc) = fg;
1580 if(d <= 0)
1582 if(t == 1)
1584 x = x + s1;
1586 else
1588 y = y + s2;
1591 d = d + incrE;
1593 else
1595 x = x + s1;
1596 y = y + s2;
1597 d = d + incrNE;
1600 maskLine = maskLine >> 1;
1601 if (!maskLine) maskLine = 1L << 15;
1606 ReturnVoid("BitMap::DrawLine ");
1609 /*****************************************************************************************
1611 NAME
1612 moHidd_BitMap_DrawRect
1614 SYNOPSIS
1615 OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawRect *msg);
1617 VOID HIDD_BM_DrawRect (OOP_Object *obj, OOP_Object *gc, WORD minX, WORD minY,
1618 WORD maxX, WORD maxY);
1620 LOCATION
1621 hidd.graphics.bitmap
1623 FUNCTION
1624 Draws a hollow rectangle. minX and minY specifies the upper
1625 left corner of the rectangle. minY and maxY specifies the lower
1626 right corner of the rectangle.
1627 The function does not clip the rectangle against the drawing area.
1629 INPUTS
1630 obj - A bitmap to draw on
1631 gc - A GC object to use for drawing
1632 minX, minY - upper left corner of the rectangle in pixels
1633 maxX, maxY - lower right corner of the rectangle in pixels
1635 RESULT
1636 None.
1638 NOTES
1639 This method is not used by the system and considered reserved.
1641 EXAMPLE
1643 BUGS
1645 SEE ALSO
1647 INTERNALS
1649 TODO
1651 *****************************************************************************************/
1653 VOID BM__Hidd_BitMap__DrawRect(OOP_Class *cl, OOP_Object *obj,
1654 struct pHidd_BitMap_DrawRect *msg)
1656 #ifdef __RESERVED__
1657 OOP_Object *gc = msg->gc;
1658 WORD addX, addY;
1660 EnterFunc(bug("BitMap::DrawRect()"));
1662 if(msg->minX == msg->maxX) addX = 0; else addX = 1;
1663 if(msg->minY == msg->maxY) addY = 0; else addY = 1;
1665 HIDD_BM_DrawLine(obj, gc, msg->minX, msg->minY , msg->maxX, msg->minY);
1666 HIDD_BM_DrawLine(obj, gc, msg->maxX, msg->minY + addY, msg->maxX, msg->maxY);
1667 HIDD_BM_DrawLine(obj, gc, msg->maxX - addX, msg->maxY, msg->minX, msg->maxY);
1668 HIDD_BM_DrawLine(obj, gc, msg->minX, msg->maxY - addY, msg->minX, msg->minY + addY);
1669 #endif
1671 ReturnVoid("BitMap::DrawRect");
1674 /*****************************************************************************************
1676 NAME
1677 moHidd_BitMap_FillRect
1679 SYNOPSIS
1680 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawRect *msg);
1682 VOID HIDD_BM_FillRect (OOP_Object *obj, OOP_Object *gc, WORD minX, WORD minY,
1683 WORD maxX, WORD maxY);
1685 LOCATION
1686 hidd.graphics.bitmap
1688 FUNCTION
1690 Draws a solid rectangle. minX and minY specifies the upper
1691 left corner of the rectangle. minY and maxY specifies the lower
1692 right corner of the rectangle.
1693 The function does not clip the rectangle against the drawing area.
1695 INPUTS
1696 obj - A bitmap to draw on
1697 gc - A GC object to use for drawing
1698 minX, minY - upper left corner of the rectangle in pixels
1699 maxX, maxY - lower right corner of the rectangle in pixels
1701 RESULT
1702 None.
1704 NOTES
1706 EXAMPLE
1708 BUGS
1710 SEE ALSO
1712 INTERNALS
1714 TODO
1715 Fill with pattern
1717 *****************************************************************************************/
1719 VOID BM__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *obj,
1720 struct pHidd_BitMap_DrawRect *msg)
1722 OOP_Object *gc = msg->gc;
1723 WORD y = msg->minY;
1724 UWORD linepat;
1726 EnterFunc(bug("BitMap::FillRect()"));
1728 linepat = GC_LINEPAT(gc);
1729 GC_LINEPAT(gc) = ~0;
1731 for(; y <= msg->maxY; y++)
1733 HIDD_BM_DrawLine(obj, gc, msg->minX, y, msg->maxX, y);
1736 GC_LINEPAT(gc) = linepat;
1738 ReturnVoid("BitMap::FillRect");
1741 /*****************************************************************************************
1743 NAME
1744 moHidd_BitMap_DrawEllipse
1746 SYNOPSIS
1747 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawEllipse *msg);
1749 VOID HIDD_BM_DrawEllipse (OOP_Object *obj, OOP_Object *gc, WORD x, WORD y,
1750 WORD rx, WORD ry);
1752 LOCATION
1753 hidd.graphics.bitmap
1755 FUNCTION
1756 Draws a hollow ellipse from the center point (x,y) with the radii
1757 rx and ry in the specified bitmap.
1758 The function does not clip the ellipse against the drawing area.
1760 INPUTS
1761 obj - A bitmap to draw on
1762 gc - A GC object to use for drawing
1763 x,y - Coordinates of center point in pixels
1764 rx,ry - ry and ry radius in pixels
1766 RESULT
1767 None.
1769 NOTES
1771 EXAMPLE
1773 BUGS
1774 Because of overflow the current code do not work with big
1775 values of rx and ry.
1777 SEE ALSO
1779 INTERNALS
1781 TODO
1782 Bugfix
1784 *****************************************************************************************/
1786 /* TODO: Try to opimize clipping here */
1788 VOID BM__Hidd_BitMap__DrawEllipse(OOP_Class *cl, OOP_Object *obj,
1789 struct pHidd_BitMap_DrawEllipse *msg)
1791 OOP_Object *gc = msg->gc;
1792 WORD x = msg->rx, y = 0; /* ellipse points */
1794 /* intermediate terms to speed up loop */
1795 LONG t1 = msg->rx * msg->rx, t2 = t1 << 1, t3 = t2 << 1;
1796 LONG t4 = msg->ry * msg->ry, t5 = t4 << 1, t6 = t5 << 1;
1797 LONG t7 = msg->rx * t5, t8 = t7 << 1, t9 = 0L;
1798 LONG d1 = t2 - t7 + (t4 >> 1); /* error terms */
1799 LONG d2 = (t1 >> 1) - t8 + t5;
1801 BOOL doclip = GC_DOCLIP(gc);
1804 EnterFunc(bug("BitMap::DrawEllipse()"));
1806 while (d2 < 0) /* til slope = -1 */
1808 /* draw 4 points using symmetry */
1810 if (doclip)
1813 if (!POINT_OUTSIDE_CLIP(gc, msg->x + x, msg->y + y))
1814 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y + y);
1816 if (!POINT_OUTSIDE_CLIP(gc, msg->x + x, msg->y - y))
1817 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y - y);
1819 if (!POINT_OUTSIDE_CLIP(gc, msg->x - x, msg->y + y))
1820 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y + y);
1822 if (!POINT_OUTSIDE_CLIP(gc, msg->x - x, msg->y - y))
1823 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y - y);
1826 else
1828 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y + y);
1829 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y - y);
1830 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y + y);
1831 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y - y);
1834 y++; /* always move up here */
1835 t9 = t9 + t3;
1836 if (d1 < 0) /* move straight up */
1838 d1 = d1 + t9 + t2;
1839 d2 = d2 + t9;
1841 else /* move up and left */
1843 x--;
1844 t8 = t8 - t6;
1845 d1 = d1 + t9 + t2 - t8;
1846 d2 = d2 + t9 + t5 - t8;
1850 do /* rest of top right quadrant */
1852 /* draw 4 points using symmetry */
1853 #if 1
1854 if (doclip)
1857 if (!POINT_OUTSIDE_CLIP(gc, msg->x + x, msg->y + y))
1858 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y + y);
1860 if (!POINT_OUTSIDE_CLIP(gc, msg->x + x, msg->y - y))
1861 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y - y);
1863 if (!POINT_OUTSIDE_CLIP(gc, msg->x - x, msg->y + y))
1864 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y + y);
1866 if (!POINT_OUTSIDE_CLIP(gc, msg->x - x, msg->y - y))
1867 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y - y);
1870 else
1873 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y + y);
1874 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y - y);
1875 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y + y);
1876 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y - y);
1878 #else
1880 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y + y);
1881 HIDD_BM_DrawPixel(obj, gc, msg->x + x, msg->y - y);
1882 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y + y);
1883 HIDD_BM_DrawPixel(obj, gc, msg->x - x, msg->y - y);
1884 #endif
1885 x--; /* always move left here */
1886 t8 = t8 - t6;
1887 if (d2 < 0) /* move up and left */
1889 y++;
1890 t9 = t9 + t3;
1891 d2 = d2 + t9 + t5 - t8;
1893 else /* move straight left */
1895 d2 = d2 + t5 - t8;
1898 } while (x >= 0);
1901 ReturnVoid("BitMap::DrawEllipse");
1904 /*****************************************************************************************
1906 NAME
1907 moHidd_BitMap_FillEllipse
1909 SYNOPSIS
1910 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawEllipse *msg);
1912 VOID HIDD_BM_FillEllipse (OOP_Object *obj, OOP_Object *gc, WORD x, WORD y,
1913 WORD ry, WORD rx);
1915 LOCATION
1916 hidd.graphics.bitmap
1918 FUNCTION
1919 Draws a solid ellipse from the center point (x,y) with the radii
1920 rx and ry in the specified bitmap.
1921 The function does not clip the ellipse against the drawing area.
1923 INPUTS
1924 obj - A bitmap to draw on
1925 gc - A GC object to use for drawing
1926 x,y - Coordinates of center point in pixels
1927 rx,ry - ry and ry radius in pixels
1929 RESULT
1930 None.
1932 NOTES
1933 This method is not used by the system and considered reserved.
1935 EXAMPLE
1937 Because of overflow the current code do not work with big
1938 values of rx and ry.
1940 SEE ALSO
1942 INTERNALS
1944 TODO
1945 Bugfix
1947 *****************************************************************************************/
1949 VOID BM__Hidd_BitMap__FillEllipse(OOP_Class *cl, OOP_Object *obj,
1950 struct pHidd_BitMap_DrawEllipse *msg)
1952 #ifdef __RESERVED__
1953 OOP_Object *gc = msg->gc;
1954 WORD x = msg->rx, y = 0; /* ellipse points */
1956 /* intermediate terms to speed up loop */
1957 LONG t1 = msg->rx * msg->rx, t2 = t1 << 1, t3 = t2 << 1;
1958 LONG t4 = msg->ry * msg->ry, t5 = t4 << 1, t6 = t5 << 1;
1959 LONG t7 = msg->rx * t5, t8 = t7 << 1, t9 = 0L;
1960 LONG d1 = t2 - t7 + (t4 >> 1); /* error terms */
1961 LONG d2 = (t1 >> 1) - t8 + t5;
1963 EnterFunc(bug("BitMap::FillEllipse()"));
1965 while (d2 < 0) /* til slope = -1 */
1967 /* draw 4 points using symmetry */
1968 HIDD_BM_DrawLine(obj, gc, msg->x - x, msg->y + y, msg->x + x, msg->y + y);
1969 HIDD_BM_DrawLine(obj, gc, msg->x - x, msg->y - y, msg->x + x, msg->y - y);
1971 y++; /* always move up here */
1972 t9 = t9 + t3;
1973 if (d1 < 0) /* move straight up */
1975 d1 = d1 + t9 + t2;
1976 d2 = d2 + t9;
1978 else /* move up and left */
1980 x--;
1981 t8 = t8 - t6;
1982 d1 = d1 + t9 + t2 - t8;
1983 d2 = d2 + t9 + t5 - t8;
1987 do /* rest of top right quadrant */
1989 /* draw 4 points using symmetry */
1990 HIDD_BM_DrawLine(obj, gc, msg->x - x, msg->y + y, msg->x + x, msg->y + y);
1991 HIDD_BM_DrawLine(obj, gc, msg->x - x, msg->y - y, msg->x + x, msg->y - y);
1993 x--; /* always move left here */
1994 t8 = t8 - t6;
1995 if (d2 < 0) /* move up and left */
1997 y++;
1998 t9 = t9 + t3;
1999 d2 = d2 + t9 + t5 - t8;
2001 else /* move straight left */
2003 d2 = d2 + t5 - t8;
2006 } while (x >= 0);
2007 #endif
2009 ReturnVoid("BitMap::FillEllipse");
2012 /*****************************************************************************************
2014 NAME
2015 moHidd_BitMap_DrawPolygon
2017 SYNOPSIS
2018 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawPolygon *msg);
2020 VOID HIDD_BM_DrawPolygon (OOP_Object *obj, OOP_Object *gc, UWORD n, WORD *coords);
2022 LOCATION
2023 hidd.graphics.bitmap
2025 FUNCTION
2026 Draws a hollow polygon from the list of coordinates in coords[].
2027 The function does not clip the polygon against the drawing area.
2029 INPUTS
2030 obj - A bitmap to draw on
2031 gc - A GC object to use for drawing
2032 n - number of coordinate pairs
2033 coords - array of n (x, y) coordinates in pixels
2035 RESULT
2036 None.
2038 NOTES
2039 This method is not used by the system and considered reserved.
2041 EXAMPLE
2043 BUGS
2045 SEE ALSO
2047 INTERNALS
2049 TODO
2051 *****************************************************************************************/
2053 VOID BM__Hidd_BitMap__DrawPolygon(OOP_Class *cl, OOP_Object *obj,
2054 struct pHidd_BitMap_DrawPolygon *msg)
2056 #ifdef __RESERVED__
2057 OOP_Object *gc = msg->gc;
2058 WORD i;
2060 EnterFunc(bug("BitMap::DrawPolygon()"));
2062 for(i = 2; i < (2 * msg->n); i = i + 2)
2064 HIDD_BM_DrawLine(obj, gc, msg->coords[i - 2], msg->coords[i - 1],
2065 msg->coords[i], msg->coords[i + 1]);
2067 #endif
2069 ReturnVoid("BitMap::DrawPolygon");
2072 /*****************************************************************************************
2074 NAME
2075 moHidd_BitMap_FillPolygon
2077 SYNOPSIS
2078 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawPolygon *msg);
2080 VOID HIDD_BM_FillPolygon (OOP_Object *obj, OOP_Object *gc, UWORD n, WORD *coords);
2082 LOCATION
2083 hidd.graphics.bitmap
2085 FUNCTION
2086 This method was initially designed for drawing solid polygons, however it was never
2087 used and implemented. At the moment it is considered reserved, its synopsis and
2088 semantics may change in future.
2090 INPUTS
2091 obj - A bitmap to draw on
2092 gc - A GC object to use for drawing
2093 n - number of coordinate pairs
2094 coords - array of n (x, y) coordinates in pixels
2096 RESULT
2097 None
2099 NOTES
2101 EXAMPLE
2103 BUGS
2104 Never used and implemented
2106 SEE ALSO
2108 INTERNALS
2110 TODO
2112 *****************************************************************************************/
2114 VOID BM__Hidd_BitMap__FillPolygon(OOP_Class *cl, OOP_Object *obj, struct pHidd_BitMap_DrawPolygon *msg)
2116 D(bug("Sorry, FillPolygon() not implemented yet in bitmap baseclass\n"));
2119 /*****************************************************************************************
2121 NAME
2122 moHidd_BitMap_DrawText
2124 SYNOPSIS
2125 OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawText *msg);
2127 VOID HIDD_BM_DrawText (OOP_Object *obj, OOP_Object *gc, WORD x, WORD y,
2128 STRPTR text, UWORD length);
2130 LOCATION
2131 hidd.graphics.bitmap
2133 FUNCTION
2134 Draws the first length characters of text at (x, y).
2135 The function does not clip the text against the drawing area.
2137 INPUTS
2138 obj - A bitmap to draw on
2139 gc - A GC object to use for drawing and font specification
2140 x, y - Position to start drawing in pixels. The x
2141 coordinate is relativ to the left side of the
2142 first character.
2143 The y coordinate is relative to the baseline of the font.
2144 text - Pointer to a Latin 1 string
2145 length - Number of characters to draw
2147 RESULT
2148 None.
2150 NOTES
2151 At the moment text drawing is processed entirely by graphics.library
2152 using BltTemplate(), which in turn uses moHodd_BitMap_PutTemplate.
2153 This method is considered obsolete.
2155 EXAMPLE
2157 BUGS
2158 The default implementation in the base class does not process styles,
2159 color and alpha-blended fonts.
2161 SEE ALSO
2163 INTERNALS
2165 TODO
2167 *****************************************************************************************/
2169 VOID BM__Hidd_BitMap__DrawText(OOP_Class *cl, OOP_Object *obj,
2170 struct pHidd_BitMap_DrawText *msg)
2172 OOP_Object *gc = msg->gc;
2173 struct TextFont *font = GC_FONT(gc);
2174 UBYTE *charPatternPtr = font->tf_CharData;
2175 UWORD modulo = font->tf_Modulo;
2176 ULONG charLog;
2177 UBYTE ch; /* current character to print */
2178 WORD fx, fx2, fy, fw; /* position and length of character in the */
2179 /* character bitmap */
2180 WORD xMem = msg->x; /* position in bitmap */
2181 WORD yMem = msg->y - font->tf_Baseline;
2182 WORD x, y, i;
2185 EnterFunc(bug("BitMap::DrawText()"));
2187 for(i = 0; i < msg->length; i++)
2189 ch = msg->text[i];
2191 if((ch < font->tf_LoChar) || (ch > font->tf_HiChar))
2193 ch = font->tf_HiChar - font->tf_LoChar + 1;
2195 else
2197 ch = ch - font->tf_LoChar;
2200 if(font->tf_Flags & FPF_PROPORTIONAL)
2202 xMem = xMem + ((UWORD *) font->tf_CharKern)[ch];
2205 charLog = ((ULONG *) font->tf_CharLoc)[ch];
2206 fx2 = charLog >> 16; /* x position of character pattern in character bitmap */
2207 fw = (UWORD) charLog; /* width of character pattern in character bitmap */
2209 y = yMem;
2211 for(fy = 0; fy < font->tf_YSize; fy ++)
2213 x = xMem;
2215 for(fx = fx2; fx < fw + fx2; fx++)
2217 if(*(charPatternPtr + fx / 8 + fy * modulo) & (128 >> (fx % 8)))
2219 HIDD_BM_DrawPixel(obj, msg->gc, x, y);
2221 x++;
2224 y++;
2227 if(font->tf_Flags & FPF_PROPORTIONAL)
2229 xMem = xMem + ((UWORD *) font->tf_CharSpace)[ch];
2231 else
2233 xMem = xMem + font->tf_XSize;
2237 ReturnVoid("BitMap::DrawText");
2240 /*****************************************************************************************
2242 NAME
2243 moHidd_BitMap_FillText
2245 SYNOPSIS
2246 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawText *msg);
2248 VOID HIDD_BM_FillText (OOP_Object *obj, OOP_Object *gc, WORD x, WORD y,
2249 STRPTR text, UWORD length);
2251 LOCATION
2252 hidd.graphics.bitmap
2254 FUNCTION
2255 Historically this method was designed to draw a text with background.
2256 It was never implemented.
2258 Currently this method is considered reserved. Its synopsis and semantics
2259 may change in future.
2261 INPUTS
2262 obj - A bitmap to draw on
2263 gc - A GC object to use for drawing
2264 x, y - Position to start drawing in pixels. The x
2265 coordinate is relative to the left side of the
2266 first character.
2267 The y coordinate is relative to the baseline of the font.
2268 text - Pointer to a Latin 1 string
2269 length - Number of characters to draw
2271 RESULT
2273 NOTES
2275 EXAMPLE
2277 BUGS
2279 SEE ALSO
2281 INTERNALS
2283 TODO
2285 *****************************************************************************************/
2287 VOID BM__Hidd_BitMap__FillText(OOP_Class *cl, OOP_Object *obj, struct pHidd_BitMap_DrawText *msg)
2289 D(bug("Sorry, FillText() not implemented yet in bitmap baseclass\n"));
2292 /*****************************************************************************************
2294 NAME
2295 moHidd_BitMap_FillSpan
2297 SYNOPSIS
2298 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_DrawText *msg);
2300 LOCATION
2301 hidd.graphics.bitmap
2303 FUNCTION
2304 Reserved, never implemented method. The definition will change in future.
2306 INPUTS
2308 RESULT
2309 None.
2311 NOTES
2313 EXAMPLE
2315 BUGS
2317 SEE ALSO
2319 INTERNALS
2321 TODO
2323 *****************************************************************************************/
2325 VOID BM__Hidd_BitMap__FillSpan(OOP_Class *cl, OOP_Object *obj, struct pHidd_BitMap_DrawText *msg)
2327 D(bug("Sorry, FillSpan() not implemented yet\n"));
2330 /*****************************************************************************************
2332 NAME
2333 moHidd_BitMap_Clear
2335 SYNOPSIS
2336 OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_Clear *msg);
2338 VOID HIDD_BM_Clear (OOP_Object *obj, OOP_Object *gc);
2340 LOCATION
2341 hidd.graphics.bitmap
2343 FUNCTION
2344 Sets all pixels of the drawing area to the background color.
2346 INPUTS
2347 obj - A bitmap to clear.
2348 gc - A GC object, specifies background color value
2350 RESULT
2352 NOTES
2353 This method is not used by the system and considered reserved. However it can
2354 be useful for display driver's own needs.
2356 EXAMPLE
2358 BUGS
2359 Default implementation in the base class sets all pixels to zero color instead of
2360 the background color from GC
2362 SEE ALSO
2364 INTERNALS
2366 TODO
2368 *****************************************************************************************/
2370 VOID BM__Hidd_BitMap__Clear(OOP_Class *cl, OOP_Object *obj, struct pHidd_BitMap_Clear *msg)
2372 WORD x, y;
2373 IPTR width, height;
2375 EnterFunc(bug("BitMap::Clear()\n"));
2377 OOP_GetAttr(obj, aHidd_BitMap_Width, &width);
2378 OOP_GetAttr(obj, aHidd_BitMap_Height, &height);
2380 for(y = 0; y < height; y++)
2382 for(x = 0; x < width; x++)
2384 HIDD_BM_PutPixel(obj, x, y, 0);
2388 ReturnVoid("BitMap::Clear");
2391 /****************************************************************************************/
2393 static LONG inline getpixfmtbpp(OOP_Class *cl, OOP_Object *o, HIDDT_StdPixFmt stdpf)
2395 OOP_Object *pf;
2396 struct HIDDBitMapData *data;
2397 SIPTR bpp = -1;
2399 data = OOP_INST_DATA(cl, o);
2401 switch (stdpf)
2403 case vHidd_StdPixFmt_Native:
2404 OOP_GetAttr(data->prot.pixfmt, aHidd_PixFmt_BytesPerPixel, &bpp);
2405 break;
2407 case vHidd_StdPixFmt_Native32:
2408 bpp = sizeof (HIDDT_Pixel);
2409 break;
2411 default:
2412 pf = HIDD_Gfx_GetPixFmt(data->gfxhidd, stdpf);
2414 if (NULL == pf)
2416 D(bug("!!! INVALID PIXFMT IN BitMap::PutImage(): %d !!!\n", stdpf));
2418 else
2420 OOP_GetAttr(pf, aHidd_PixFmt_BytesPerPixel, &bpp);
2422 break;
2425 return bpp;
2428 /*****************************************************************************************
2430 NAME
2431 moHidd_BitMap_GetImage
2433 SYNOPSIS
2434 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_GetImage *msg);
2436 VOID HIDD_BM_GetImage (OOP_Object *obj, UBYTE *pixels, ULONG modulo, WORD x, WORD y,
2437 WORD width, WORD height, HIDDT_StdPixFmt pixFmt);
2439 LOCATION
2440 hidd.graphics.bitmap
2442 FUNCTION
2444 INPUTS
2445 obj -
2446 pixels -
2447 modulo -
2448 x, y -
2449 width -
2450 height -
2451 pixFmt -
2453 RESULT
2455 NOTES
2457 EXAMPLE
2459 BUGS
2461 SEE ALSO
2463 INTERNALS
2465 *****************************************************************************************/
2467 VOID BM__Hidd_BitMap__GetImage(OOP_Class *cl, OOP_Object *o,
2468 struct pHidd_BitMap_GetImage *msg)
2470 WORD x, y;
2471 UBYTE *pixarray = (UBYTE *)msg->pixels;
2472 APTR ppixarray = &pixarray;
2473 LONG bpp;
2474 struct HIDDBitMapData *data;
2476 data = OOP_INST_DATA(cl, o);
2478 EnterFunc(bug("BitMap::GetImage(x=%d, y=%d, width=%d, height=%d)\n"
2479 , msg->x, msg->y, msg->width, msg->height));
2482 bpp = getpixfmtbpp(cl, o, msg->pixFmt);
2483 if (-1 == bpp)
2485 D(bug("!!! INVALID PIXFMT IN BitMap::GetImage(): %d !!!\n", msg->pixFmt));
2486 return;
2490 switch(msg->pixFmt)
2492 case vHidd_StdPixFmt_Native:
2493 case vHidd_StdPixFmt_Native32:
2494 for (y = 0; y < msg->height; y ++)
2496 for (x = 0; x < msg->width; x ++)
2498 register HIDDT_Pixel pix;
2500 pix = HIDD_BM_GetPixel(o, x + msg->x , y + msg->y);
2502 switch (bpp)
2504 case 1:
2505 *pixarray++ = pix;
2506 break;
2508 case 2:
2509 *((UWORD *)pixarray) = pix;
2510 pixarray += 2;
2511 break;
2513 case 3:
2514 #if AROS_BIG_ENDIAN
2515 pixarray[0] = (pix >> 16) & 0xFF;
2516 pixarray[1] = (pix >> 8) & 0xFF;
2517 pixarray[2] = pix & 0xFF;
2518 #else
2519 pixarray[0] = pix & 0xFF;
2520 pixarray[1] = (pix >> 8) & 0xFF;
2521 pixarray[2] = (pix >> 16) & 0xFF;
2522 #endif
2523 pixarray += 3;
2524 break;
2526 case 4:
2527 *(ULONG *)pixarray = pix;
2528 pixarray += 4;
2529 break;
2534 pixarray += (msg->modulo - msg->width * bpp);
2537 break;
2539 default:
2541 OOP_Object *dstpf;
2542 APTR buf, srcPixels;
2544 dstpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
2546 buf = srcPixels = AllocVec(msg->width * sizeof(HIDDT_Pixel), MEMF_PUBLIC);
2547 if (buf)
2549 for(y = 0; y < msg->height; y++)
2551 HIDD_BM_GetImage(o,
2552 buf,
2554 msg->x,
2555 msg->y + y,
2556 msg->width,
2558 vHidd_StdPixFmt_Native);
2560 HIDD_BM_ConvertPixels(o,
2561 &srcPixels,
2562 (HIDDT_PixelFormat *)data->prot.pixfmt,
2564 (APTR *)ppixarray,
2565 (HIDDT_PixelFormat *)dstpf,
2566 msg->modulo,
2567 msg->width,
2569 NULL);
2572 FreeVec(buf);
2575 break;
2577 } /* switch(msg->pixFmt) */
2579 ReturnVoid("BitMap::GetImage");
2582 /*****************************************************************************************
2584 NAME
2585 moHidd_BitMap_PutImage
2587 SYNOPSIS
2588 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_PutImage *msg);
2590 VOID HIDD_BM_PutImage (OOP_Object *obj, OOP_Object *gc, UBYTE *pixels, ULONG modulo,
2591 WORD x, WORD y, WORD width, WORD height, HIDDT_StdPixFmt pixFmt);
2593 LOCATION
2594 hidd.graphics.bitmap
2596 FUNCTION
2598 INPUTS
2599 obj -
2600 gc -
2601 pixels -
2602 modulo -
2603 x, y -
2604 width -
2605 height -
2606 pixFmt -
2608 RESULT
2610 NOTES
2612 EXAMPLE
2614 BUGS
2616 SEE ALSO
2618 INTERNALS
2620 *****************************************************************************************/
2622 VOID BM__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o,
2623 struct pHidd_BitMap_PutImage *msg)
2625 WORD x, y;
2626 UBYTE *pixarray = (UBYTE *)msg->pixels;
2627 APTR ppixarray = &pixarray;
2628 ULONG old_fg;
2629 LONG bpp;
2630 struct HIDDBitMapData *data;
2631 OOP_Object *gc = msg->gc;
2633 data = OOP_INST_DATA(cl, o);
2635 EnterFunc(bug("BitMap::PutImage(x=%d, y=%d, width=%d, height=%d)\n"
2636 , msg->x, msg->y, msg->width, msg->height));
2638 if (msg->width <= 0 || msg->height <= 0)
2639 return;
2641 bpp = getpixfmtbpp(cl, o, msg->pixFmt);
2642 if (-1 == bpp)
2644 D(bug("!!! INVALID PIXFMT IN BitMap::PutImage(): %d !!!\n", msg->pixFmt));
2645 return;
2648 switch(msg->pixFmt)
2650 case vHidd_StdPixFmt_Native:
2651 case vHidd_StdPixFmt_Native32:
2653 /* Preserve old fg pen */
2654 old_fg = GC_FG(gc);
2656 for (y = 0; y < msg->height; y ++)
2658 for (x = 0; x < msg->width; x ++)
2660 register HIDDT_Pixel pix = 0;
2662 switch (bpp)
2664 case 1:
2665 pix = *((UBYTE *)pixarray);
2666 pixarray ++;
2667 break;
2669 case 2:
2670 pix = *((UWORD *)pixarray);
2671 pixarray += 2;
2672 break;
2674 case 3:
2675 #if AROS_BIG_ENDIAN
2676 pix = ((UBYTE *)pixarray)[0] << 16;
2677 pix |= ((UBYTE *)pixarray)[1] << 8;
2678 pix |= ((UBYTE *)pixarray)[2];
2679 #else
2680 pix = ((UBYTE *)pixarray)[2] << 16;
2681 pix |= ((UBYTE *)pixarray)[1] << 8;
2682 pix |= ((UBYTE *)pixarray)[0];
2683 #endif
2684 pixarray += 3;
2685 break;
2687 case 4:
2688 pix = *((ULONG *)pixarray); pixarray += 4;
2689 break;
2693 GC_FG(gc) = pix;
2695 HIDD_BM_DrawPixel(o, gc, x + msg->x , y + msg->y);
2697 pixarray += (msg->modulo - msg->width * bpp);
2700 GC_FG(gc) = old_fg;
2701 break;
2703 default:
2705 OOP_Object *srcpf;
2706 APTR buf, destPixels;
2708 srcpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
2710 buf = destPixels = AllocVec(msg->width * sizeof(HIDDT_Pixel), MEMF_PUBLIC);
2711 if (buf)
2713 for(y = 0; y < msg->height; y++)
2715 HIDD_BM_ConvertPixels(o,
2716 (APTR *)ppixarray,
2717 (HIDDT_PixelFormat *)srcpf,
2718 msg->modulo,
2719 &destPixels,
2720 (HIDDT_PixelFormat *)data->prot.pixfmt,
2722 msg->width,
2724 NULL);
2726 HIDD_BM_PutImage(o,
2727 msg->gc,
2728 buf,
2730 msg->x,
2731 msg->y + y,
2732 msg->width,
2734 vHidd_StdPixFmt_Native);
2736 FreeVec(buf);
2739 break;
2741 } /* switch(msg->pixFmt) */
2743 ReturnVoid("BitMap::PutImage");
2746 /****************************************************************************************/
2748 int static inline
2749 __attribute__((always_inline, const)) do_alpha(int a, int v)
2751 int tmp = (a*v);
2752 return ((tmp<<8) + tmp + 32768)>>16;
2755 /*****************************************************************************************
2757 NAME
2758 moHidd_BitMap_PutAlphaImage
2760 SYNOPSIS
2761 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_PutAlphaImage *msg);
2763 VOID HIDD_BM_PutAlphaImage (OOP_Object *obj, OOP_Object *gc, UBYTE *pixels, ULONG modulo,
2764 WORD x, WORD y, WORD width, WORD height);
2766 LOCATION
2767 hidd.graphics.bitmap
2769 FUNCTION
2771 INPUTS
2772 obj -
2773 gc -
2774 pixels -
2775 modulo -
2776 x, y -
2777 width -
2778 height -
2780 RESULT
2782 NOTES
2784 EXAMPLE
2786 BUGS
2788 SEE ALSO
2790 INTERNALS
2792 *****************************************************************************************/
2794 VOID BM__Hidd_BitMap__PutAlphaImage(OOP_Class *cl, OOP_Object *o,
2795 struct pHidd_BitMap_PutAlphaImage *msg)
2797 WORD x, y;
2798 ULONG *pixarray = (ULONG *)msg->pixels;
2799 ULONG *buf, *xbuf;
2800 PIXBUF_DECLARE_VARS
2802 EnterFunc(bug("BitMap::PutAlphaImage(x=%d, y=%d, width=%d, height=%d)\n"
2803 , msg->x, msg->y, msg->width, msg->height));
2805 if (msg->width <= 0 || msg->height <= 0)
2806 return;
2808 PIXBUF_ALLOC(buf, msg->width * sizeof(ULONG), msg->height);
2810 if (buf)
2812 HIDDT_DrawMode old_drmd = GC_DRMD(msg->gc);
2813 GC_DRMD(msg->gc) = vHidd_GC_DrawMode_Copy;
2815 xbuf = buf;
2817 for(y = msg->y; y < msg->y + msg->height; y++)
2819 if (PIXBUF_TIME_TO_START_PROCESS)
2821 WORD height = PIXBUF_LINES_TO_PROCESS;
2823 HIDD_BM_GetImage(o,
2824 (UBYTE *)buf,
2825 msg->width * sizeof(ULONG),
2826 msg->x,
2828 msg->width,
2829 height,
2830 vHidd_StdPixFmt_ARGB32);
2833 for(x = 0; x < msg->width; x++)
2835 ULONG destpix;
2836 ULONG srcpix;
2837 LONG src_red, src_green, src_blue, src_alpha;
2838 LONG dst_red, dst_green, dst_blue;
2840 srcpix = *pixarray++;
2842 #if AROS_BIG_ENDIAN
2843 if ((srcpix & 0xFF000000) == 0xFF000000)
2844 xbuf[x] = srcpix;
2845 else if ((srcpix & 0xFF000000) != 0)
2846 #else
2847 if ((srcpix & 0xFF) == 0xFF)
2848 xbuf[x] = srcpix;
2849 else if ((srcpix & 0xFF) != 0)
2850 #endif
2852 #if AROS_BIG_ENDIAN
2853 src_red = (srcpix & 0x00FF0000) >> 16;
2854 src_green = (srcpix & 0x0000FF00) >> 8;
2855 src_blue = (srcpix & 0x000000FF);
2856 src_alpha = (srcpix & 0xFF000000) >> 24;
2857 #else
2858 src_red = (srcpix & 0x0000FF00) >> 8;
2859 src_green = (srcpix & 0x00FF0000) >> 16;
2860 src_blue = (srcpix & 0xFF000000) >> 24;
2861 src_alpha = (srcpix & 0x000000FF);
2862 #endif
2864 destpix = xbuf[x];
2865 #if AROS_BIG_ENDIAN
2866 dst_red = (destpix & 0x00FF0000) >> 16;
2867 dst_green = (destpix & 0x0000FF00) >> 8;
2868 dst_blue = (destpix & 0x000000FF);
2869 #else
2870 dst_red = (destpix & 0x0000FF00) >> 8;
2871 dst_green = (destpix & 0x00FF0000) >> 16;
2872 dst_blue = (destpix & 0xFF000000) >> 24;
2873 #endif
2875 dst_red += do_alpha(src_alpha, src_red - dst_red);
2876 dst_green += do_alpha(src_alpha, src_green - dst_green);
2877 dst_blue += do_alpha(src_alpha, src_blue - dst_blue);
2879 #if AROS_BIG_ENDIAN
2880 destpix &= 0xFF000000;
2881 destpix |= (dst_red << 16) + (dst_green << 8) + (dst_blue);
2882 #else
2883 destpix &= 0x000000FF;
2884 destpix |= (dst_blue << 24) + (dst_green << 16) + (dst_red << 8);
2885 #endif
2887 xbuf[x] = destpix;
2889 } /* for(x = 0; x < msg->width; x++) */
2891 if (PIXBUF_TIME_TO_END_PROCESS)
2893 LONG height = PIXBUF_LINES_TO_PROCESS;
2895 HIDD_BM_PutImage(o,
2896 msg->gc,
2897 (UBYTE *)buf,
2898 msg->width * sizeof(ULONG),
2899 msg->x,
2900 y - height + 1,
2901 msg->width,
2902 height,
2903 vHidd_StdPixFmt_ARGB32);
2904 xbuf = buf;
2906 else
2908 xbuf += msg->width;
2911 pixarray = (ULONG *)((UBYTE *)pixarray + msg->modulo - msg->width * 4);
2913 PIXBUF_NEXT_LINE;
2916 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
2918 GC_DRMD(msg->gc) = old_drmd;
2920 PIXBUF_FREE(buf);
2922 } /* if (buf) */
2923 else
2925 for(y = msg->y; y < msg->y + msg->height; y++)
2927 for(x = msg->x; x < msg->x + msg->width; x++)
2929 HIDDT_Pixel destpix;
2930 HIDDT_Color col;
2931 ULONG srcpix;
2932 LONG src_red, src_green, src_blue, src_alpha;
2933 LONG dst_red, dst_green, dst_blue;
2935 destpix = HIDD_BM_GetPixel(o, x, y);
2936 HIDD_BM_UnmapPixel(o, destpix, &col);
2938 srcpix = *pixarray++;
2939 #if AROS_BIG_ENDIAN
2940 src_red = (srcpix & 0x00FF0000) >> 16;
2941 src_green = (srcpix & 0x0000FF00) >> 8;
2942 src_blue = (srcpix & 0x000000FF);
2943 src_alpha = (srcpix & 0xFF000000) >> 24;
2944 #else
2945 src_red = (srcpix & 0x0000FF00) >> 8;
2946 src_green = (srcpix & 0x00FF0000) >> 16;
2947 src_blue = (srcpix & 0xFF000000) >> 24;
2948 src_alpha = (srcpix & 0x000000FF);
2949 #endif
2951 dst_red = col.red >> 8;
2952 dst_green = col.green >> 8;
2953 dst_blue = col.blue >> 8;
2955 dst_red += do_alpha(src_alpha, src_red - dst_red);
2956 dst_green += do_alpha(src_alpha, src_green - dst_green);
2957 dst_blue += do_alpha(src_alpha, src_blue - dst_blue);
2959 col.red = dst_red << 8;
2960 col.green = dst_green << 8;
2961 col.blue = dst_blue << 8;
2963 HIDD_BM_PutPixel(o, x, y, HIDD_BM_MapColor(o, &col));
2965 } /* for(x = msg->x; x < msg->x + msg->width; x++) */
2967 pixarray = (ULONG *)((UBYTE *)pixarray + msg->modulo - msg->width * 4);
2969 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
2973 ReturnVoid("BitMap::PutAlphaImage");
2976 /*****************************************************************************************
2978 NAME
2979 moHidd_BitMap_PutTemplate
2981 SYNOPSIS
2982 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_PutTemplate *msg);
2984 VOID HIDD_BM_PutTemplate (OOP_Object *obj, OOP_Object *gc, UBYTE *template, ULONG modulo,
2985 WORD srcx, WORD x, WORD y, WORD width, WORD height, BOOL inverttemplate);
2987 LOCATION
2988 hidd.graphics.bitmap
2990 FUNCTION
2992 INPUTS
2993 obj -
2994 gc -
2995 template -
2996 modulo -
2997 srcx -
2998 x, y -
2999 width -
3000 height -
3001 inverttemplate -
3003 RESULT
3005 NOTES
3007 EXAMPLE
3009 BUGS
3011 SEE ALSO
3013 INTERNALS
3015 *****************************************************************************************/
3017 VOID BM__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o,
3018 struct pHidd_BitMap_PutTemplate *msg)
3020 WORD x, y;
3021 UBYTE *bitarray;
3022 HIDDT_Pixel *buf, *xbuf, bitmask;
3023 OOP_Object *gc = msg->gc;
3024 WORD type = 0;
3025 PIXBUF_DECLARE_VARS
3027 EnterFunc(bug("BitMap::PutTemplate(x=%d, y=%d, width=%d, height=%d)\n"
3028 , msg->x, msg->y, msg->width, msg->height));
3030 if (msg->width <= 0 || msg->height <= 0)
3031 return;
3033 if (GC_COLEXP(gc) == vHidd_GC_ColExp_Transparent)
3035 type = 0;
3037 else if (GC_DRMD(gc) == vHidd_GC_DrawMode_Invert)
3039 type = 2;
3041 else
3043 type = 4;
3046 if (msg->inverttemplate) type++;
3048 bitarray = msg->template + ((msg->srcx / 16) * 2);
3049 bitmask = 0x8000 >> (msg->srcx & 0xF);
3051 PIXBUF_ALLOC(buf, msg->width * sizeof(HIDDT_Pixel), msg->height);
3053 if (buf)
3055 HIDDT_DrawMode old_drmd = GC_DRMD(msg->gc);
3056 HIDDT_Pixel fg = GC_FG(msg->gc);
3057 HIDDT_Pixel bg = GC_BG(msg->gc);
3059 GC_DRMD(msg->gc) = vHidd_GC_DrawMode_Copy;
3061 xbuf = buf;
3063 for(y = msg->y; y < msg->y + msg->height; y++)
3065 ULONG mask = bitmask;
3066 UWORD *array = (UWORD *)bitarray;
3067 UWORD bitword = AROS_BE2WORD(*array);
3069 if ((type < 4) && PIXBUF_TIME_TO_START_PROCESS)
3071 WORD height = PIXBUF_LINES_TO_PROCESS;
3073 HIDD_BM_GetImage(o,
3074 (UBYTE *)buf,
3075 msg->width * sizeof(HIDDT_Pixel),
3076 msg->x,
3078 msg->width,
3079 height,
3080 vHidd_StdPixFmt_Native32);
3084 switch(type)
3086 case 0: /* JAM1 */
3087 for(x = 0; x < msg->width; x++)
3089 if (bitword & mask) xbuf[x] = fg;
3091 mask >>= 1;
3092 if (!mask)
3094 mask = 0x8000;
3095 array++;
3096 bitword = AROS_BE2WORD(*array);
3099 } /* for(x = 0; x < msg->width; x++) */
3100 break;
3102 case 1: /* JAM1 | INVERSVID */
3103 for(x = 0; x < msg->width; x++)
3105 if (!(bitword & mask)) xbuf[x] = fg;
3107 mask >>= 1;
3108 if (!mask)
3110 mask = 0x8000;
3111 array++;
3112 bitword = AROS_BE2WORD(*array);
3115 } /* for(x = 0; x < msg->width; x++) */
3116 break;
3118 case 2: /* COMPLEMENT */
3119 for(x = 0; x < msg->width; x++)
3121 if (bitword & mask) xbuf[x] = ~xbuf[x];
3123 mask >>= 1;
3124 if (!mask)
3126 mask = 0x8000;
3127 array++;
3128 bitword = AROS_BE2WORD(*array);
3130 } /* for(x = 0; x < msg->width; x++) */
3131 break;
3133 case 3: /* COMPLEMENT | INVERSVID*/
3134 for(x = 0; x < msg->width; x++)
3136 if (!(bitword & mask)) xbuf[x] = ~xbuf[x];
3138 mask >>= 1;
3139 if (!mask)
3141 mask = 0x8000;
3142 array++;
3143 bitword = AROS_BE2WORD(*array);
3145 } /* for(x = 0; x < msg->width; x++) */
3146 break;
3148 case 4: /* JAM2 */
3149 for(x = 0; x < msg->width; x++)
3151 xbuf[x] = (bitword & mask) ? fg : bg;
3153 mask >>= 1;
3154 if (!mask)
3156 mask = 0x8000;
3157 array++;
3158 bitword = AROS_BE2WORD(*array);
3161 } /* for(x = 0; x < msg->width; x++) */
3162 break;
3164 case 5: /* JAM2 | INVERSVID */
3165 for(x = 0; x < msg->width; x++)
3167 xbuf[x] = (bitword & mask) ? bg : fg;
3169 mask >>= 1;
3170 if (!mask)
3172 mask = 0x8000;
3173 array++;
3174 bitword = AROS_BE2WORD(*array);
3176 } /* for(x = 0; x < msg->width; x++) */
3177 break;
3179 } /* switch(type) */
3181 if (PIXBUF_TIME_TO_END_PROCESS)
3183 LONG height = PIXBUF_LINES_TO_PROCESS;
3185 //kprintf(" PutImage at %d height %d __height %d __bufy %d __worky %d\n",
3186 // y - height + 1 - msg->y, height, __height, __bufy, __worky);
3188 HIDD_BM_PutImage(o,
3189 msg->gc,
3190 (UBYTE *)buf,
3191 msg->width * sizeof(HIDDT_Pixel),
3192 msg->x,
3193 y - height + 1,
3194 msg->width,
3195 height,
3196 vHidd_StdPixFmt_Native32);
3197 xbuf = buf;
3199 else
3201 xbuf += msg->width;
3204 bitarray += msg->modulo;
3206 PIXBUF_NEXT_LINE;
3208 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
3210 GC_DRMD(msg->gc) = old_drmd;
3212 PIXBUF_FREE(buf);
3214 } /* if (buf) */
3215 else
3220 ReturnVoid("BitMap::PutTemplate");
3223 /*****************************************************************************************
3225 NAME
3226 moHidd_BitMap_PutAlphaTemplate
3228 SYNOPSIS
3229 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_PutAlphaTemplate *msg);
3231 VOID HIDD_BM_PutAlphaTemplate (OOP_Object *obj, OOP_Object *gc, UBYTE *alpha, ULONG modulo,
3232 WORD x, WORD y, WORD width, WORD height, BOOL invertalpha);
3234 LOCATION
3235 hidd.graphics.bitmap
3237 FUNCTION
3239 INPUTS
3240 obj -
3241 gc -
3242 alpha -
3243 modulo -
3244 x, y -
3245 width -
3246 height -
3247 invertalpha -
3249 RESULT
3251 NOTES
3253 EXAMPLE
3255 BUGS
3257 SEE ALSO
3259 INTERNALS
3261 *****************************************************************************************/
3263 VOID BM__Hidd_BitMap__PutAlphaTemplate(OOP_Class *cl, OOP_Object *o,
3264 struct pHidd_BitMap_PutAlphaTemplate *msg)
3266 WORD x, y;
3267 UBYTE *pixarray = msg->alpha;
3268 ULONG *buf, *xbuf;
3269 OOP_Object *gc = msg->gc;
3270 HIDDT_Color color;
3271 LONG a_red, a_green, a_blue;
3272 LONG b_red = 0;
3273 LONG b_green = 0;
3274 LONG b_blue = 0;
3275 WORD type = 0;
3276 PIXBUF_DECLARE_VARS
3278 EnterFunc(bug("BitMap::PutAlphaTemplate(x=%d, y=%d, width=%d, height=%d)\n"
3279 , msg->x, msg->y, msg->width, msg->height));
3281 if (msg->width <= 0 || msg->height <= 0)
3282 return;
3284 HIDD_BM_UnmapPixel(o, GC_FG(gc), &color);
3286 a_red = color.red >> 8;
3287 a_green = color.green >> 8;
3288 a_blue = color.blue >> 8;
3290 if (GC_COLEXP(gc) == vHidd_GC_ColExp_Transparent)
3292 type = 0;
3294 else if (GC_DRMD(gc) == vHidd_GC_DrawMode_Invert)
3296 type = 2;
3298 else
3300 type = 4;
3302 HIDD_BM_UnmapPixel(o, GC_BG(gc), &color);
3303 b_red = color.red >> 8;
3304 b_green = color.green >> 8;
3305 b_blue = color.blue >> 8;
3308 if (msg->invertalpha) type++;
3310 PIXBUF_ALLOC(buf, msg->width * sizeof(ULONG), msg->height);
3312 if (buf)
3314 HIDDT_DrawMode old_drmd = GC_DRMD(msg->gc);
3315 GC_DRMD(msg->gc) = vHidd_GC_DrawMode_Copy;
3317 xbuf = buf;
3319 for(y = msg->y; y < msg->y + msg->height; y++)
3321 if ((type < 4) && PIXBUF_TIME_TO_START_PROCESS)
3323 WORD height = PIXBUF_LINES_TO_PROCESS;
3325 HIDD_BM_GetImage(o,
3326 (UBYTE *)buf,
3327 msg->width * sizeof(ULONG),
3328 msg->x,
3330 msg->width,
3331 height,
3332 vHidd_StdPixFmt_ARGB32);
3335 switch(type)
3337 case 0: /* JAM1 */
3338 for(x = 0; x < msg->width; x++)
3340 ULONG destpix;
3341 LONG dst_red, dst_green, dst_blue, alpha;
3343 alpha = *pixarray++;
3345 destpix = xbuf[x];
3347 #if AROS_BIG_ENDIAN
3348 dst_red = (destpix & 0x00FF0000) >> 16;
3349 dst_green = (destpix & 0x0000FF00) >> 8;
3350 dst_blue = (destpix & 0x000000FF);
3351 #else
3352 dst_red = (destpix & 0x0000FF00) >> 8;
3353 dst_green = (destpix & 0x00FF0000) >> 16;
3354 dst_blue = (destpix & 0xFF000000) >> 24;
3355 #endif
3357 dst_red += do_alpha(alpha, a_red - dst_red);
3358 dst_green += do_alpha(alpha, a_green - dst_green);
3359 dst_blue += do_alpha(alpha, a_blue - dst_blue);
3361 #if AROS_BIG_ENDIAN
3362 destpix = (dst_red << 16) + (dst_green << 8) + (dst_blue);
3363 #else
3364 destpix = (dst_blue << 24) + (dst_green << 16) + (dst_red << 8);
3365 #endif
3367 xbuf[x] = destpix;
3369 } /* for(x = 0; x < msg->width; x++) */
3370 break;
3372 case 1: /* JAM1 | INVERSVID */
3373 for(x = 0; x < msg->width; x++)
3375 ULONG destpix;
3376 LONG dst_red, dst_green, dst_blue, alpha;
3378 alpha = (*pixarray++) ^ 255;
3380 destpix = xbuf[x];
3382 #if AROS_BIG_ENDIAN
3383 dst_red = (destpix & 0x00FF0000) >> 16;
3384 dst_green = (destpix & 0x0000FF00) >> 8;
3385 dst_blue = (destpix & 0x000000FF);
3386 #else
3387 dst_red = (destpix & 0x0000FF00) >> 8;
3388 dst_green = (destpix & 0x00FF0000) >> 16;
3389 dst_blue = (destpix & 0xFF000000) >> 24;
3390 #endif
3392 dst_red += do_alpha(alpha, a_red - dst_red);
3393 dst_green += do_alpha(alpha, a_green - dst_green);
3394 dst_blue += do_alpha(alpha, a_blue - dst_blue);
3396 #if AROS_BIG_ENDIAN
3397 destpix = (dst_red << 16) + (dst_green << 8) + (dst_blue);
3398 #else
3399 destpix = (dst_blue << 24) + (dst_green << 16) + (dst_red << 8);
3400 #endif
3402 xbuf[x] = destpix;
3404 } /* for(x = 0; x < msg->width; x++) */
3405 break;
3407 case 2: /* COMPLEMENT */
3408 for(x = 0; x < msg->width; x++)
3410 ULONG destpix;
3411 UBYTE alpha;
3413 alpha = *pixarray++;
3415 destpix = xbuf[x];
3416 if (alpha >= 0x80) destpix = ~destpix;
3417 xbuf[x] = destpix;
3419 } /* for(x = 0; x < msg->width; x++) */
3420 break;
3422 case 3: /* COMPLEMENT | INVERSVID*/
3423 for(x = 0; x < msg->width; x++)
3425 ULONG destpix;
3426 UBYTE alpha;
3428 alpha = *pixarray++;
3430 destpix = xbuf[x];
3431 if (alpha < 0x80) destpix = ~destpix;
3432 xbuf[x] = destpix;
3434 } /* for(x = 0; x < msg->width; x++) */
3435 break;
3437 case 4: /* JAM2 */
3438 for(x = 0; x < msg->width; x++)
3440 ULONG destpix;
3441 LONG dst_red, dst_green, dst_blue, alpha;
3443 alpha = *pixarray++;
3445 dst_red = b_red + ((a_red - b_red) * alpha) / 256;
3446 dst_green = b_green + ((a_green - b_green) * alpha) / 256;
3447 dst_blue = b_blue + ((a_blue - b_blue) * alpha) / 256;
3449 #if AROS_BIG_ENDIAN
3450 destpix = (dst_red << 16) + (dst_green << 8) + (dst_blue);
3451 #else
3452 destpix = (dst_blue << 24) + (dst_green << 16) + (dst_red << 8);
3453 #endif
3455 xbuf[x] = destpix;
3457 } /* for(x = 0; x < msg->width; x++) */
3458 break;
3460 case 5: /* JAM2 | INVERSVID */
3461 for(x = 0; x < msg->width; x++)
3463 ULONG destpix;
3464 LONG dst_red, dst_green, dst_blue, alpha;
3466 alpha = (*pixarray++) ^ 255;
3468 dst_red = b_red + ((a_red - b_red) * alpha) / 256;
3469 dst_green = b_green + ((a_green - b_green) * alpha) / 256;
3470 dst_blue = b_blue + ((a_blue - b_blue) * alpha) / 256;
3472 #if AROS_BIG_ENDIAN
3473 destpix = (dst_red << 16) + (dst_green << 8) + (dst_blue);
3474 #else
3475 destpix = (dst_blue << 24) + (dst_green << 16) + (dst_red << 8);
3476 #endif
3478 xbuf[x] = destpix;
3480 } /* for(x = 0; x < msg->width; x++) */
3481 break;
3483 } /* switch(type) */
3485 if (PIXBUF_TIME_TO_END_PROCESS)
3487 LONG height = PIXBUF_LINES_TO_PROCESS;
3489 HIDD_BM_PutImage(o,
3490 msg->gc,
3491 (UBYTE *)buf,
3492 msg->width * sizeof(ULONG),
3493 msg->x,
3494 y - height + 1,
3495 msg->width,
3496 height,
3497 vHidd_StdPixFmt_ARGB32);
3499 xbuf = buf;
3501 else
3503 xbuf += msg->width;
3506 pixarray += msg->modulo - msg->width;
3508 PIXBUF_NEXT_LINE
3510 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
3512 GC_DRMD(msg->gc) = old_drmd;
3514 PIXBUF_FREE(buf);
3516 } /* if (buf) */
3517 else
3522 ReturnVoid("BitMap::PutAlphaTemplate");
3525 /*****************************************************************************************
3527 NAME
3528 moHidd_BitMap_PutPattern
3530 SYNOPSIS
3531 VOID OOP_DoMethod(OOP_Object *o, struct pHidd_BitMap_PutPattern *msg);
3533 VOID HIDD_BM_PutPattern(OOP_Object *obj, OOP_Object *gc, UBYTE *pattern,
3534 WORD patternsrcx, WORD patternsrcy, WORD patternheight, WORD patterndepth,
3535 HIDDT_PixelLUT *patternlut, BOOL invertpattern, UBYTE *mask,
3536 ULONG maskmodulo, WORD masksrcx, WORD x, WORD y,
3537 WORD width, WORD height);
3539 LOCATION
3540 hidd.graphics.bitmap
3542 FUNCTION
3544 INPUTS
3545 obj - A bitmap to draw on
3546 gc - A GC object to use for drawing
3547 pattern -
3548 patternsrcx -
3549 patternsrcy -
3550 patternheight -
3551 patterndepth -
3552 patternlut -
3553 invertpattern -
3554 mask -
3555 maskmodulo -
3556 masksrcx -
3557 x, y -
3558 width -
3559 height -
3561 RESULT
3562 None
3564 NOTES
3566 EXAMPLE
3568 BUGS
3570 SEE ALSO
3572 INTERNALS
3574 *****************************************************************************************/
3576 VOID BM__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o,
3577 struct pHidd_BitMap_PutPattern *msg)
3579 WORD x, y;
3580 UBYTE *patarray;
3581 UBYTE *maskarray = 0;
3582 ULONG maskmask = 0;
3583 ULONG *buf, *xbuf, patmask;
3584 OOP_Object *gc = msg->gc;
3585 WORD type = 0;
3586 PIXBUF_DECLARE_VARS
3588 EnterFunc(bug("BitMap::PutPattern(x=%d, y=%d, width=%d, height=%d)\n"
3589 , msg->x, msg->y, msg->width, msg->height));
3591 if (msg->width <= 0 || msg->height <= 0)
3592 return;
3594 if (msg->patterndepth > 1)
3596 type = 6;
3598 else
3600 if (GC_COLEXP(gc) == vHidd_GC_ColExp_Transparent)
3602 type = 0;
3604 else if (GC_DRMD(gc) == vHidd_GC_DrawMode_Invert)
3606 type = 2;
3608 else
3610 type = 4;
3613 if (msg->invertpattern) type++;
3616 patarray = msg->pattern;
3617 patmask = 0x8000 >> (msg->patternsrcx & 0xF);
3619 if ((maskarray = msg->mask))
3621 maskarray += (msg->masksrcx / 16) * 2;
3622 maskmask = 0x8000 >> (msg->masksrcx & 0xF);
3625 PIXBUF_ALLOC(buf, msg->width * sizeof(ULONG), msg->height);
3627 if (buf)
3629 HIDDT_DrawMode old_drmd = GC_DRMD(msg->gc);
3630 ULONG fg = GC_FG(msg->gc);
3631 ULONG bg = GC_BG(msg->gc);
3633 GC_DRMD(msg->gc) = vHidd_GC_DrawMode_Copy;
3635 xbuf = buf;
3637 for(y = msg->y; y < msg->y + msg->height; y++)
3639 ULONG pmask = patmask;
3640 ULONG mmask = maskmask;
3641 UWORD *parray = ((UWORD *)patarray) + ((y + msg->patternsrcy - msg->y) % msg->patternheight);
3642 UWORD patword = AROS_BE2WORD(*parray);
3643 UWORD *marray = NULL;
3644 UWORD maskword = 0;
3646 if (maskarray)
3648 marray = (UWORD *)maskarray;
3649 maskword = AROS_BE2WORD(*marray);
3652 if (((type < 4) || maskarray) && PIXBUF_TIME_TO_START_PROCESS)
3654 WORD height = PIXBUF_LINES_TO_PROCESS;
3656 //kprintf(" GetImage at %d height %d\n", y - msg->y, height);
3658 HIDD_BM_GetImage(o,
3659 (UBYTE *)buf,
3660 msg->width * sizeof(ULONG),
3661 msg->x,
3663 msg->width,
3664 height,
3665 vHidd_StdPixFmt_Native32);
3669 switch(type)
3671 case 0: /* JAM1 */
3672 for(x = 0; x < msg->width; x++)
3674 if (!maskarray || (maskword & mmask))
3676 if (patword & pmask) xbuf[x] = fg;
3679 if (maskarray)
3681 mmask >>= 1;
3682 if (!mmask)
3684 mmask = 0x8000;
3685 marray++;
3686 maskword = AROS_BE2WORD(*marray);
3690 pmask >>= 1;
3691 if (!pmask) pmask = 0x8000;
3693 } /* for(x = 0; x < msg->width; x++) */
3694 break;
3696 case 1: /* JAM1 | INVERSVID */
3697 for(x = 0; x < msg->width; x++)
3699 if (!maskarray || (maskword & mmask))
3701 if (!(patword & pmask)) xbuf[x] = fg;
3704 if (maskarray)
3706 mmask >>= 1;
3707 if (!mmask)
3709 mmask = 0x8000;
3710 marray++;
3711 maskword = AROS_BE2WORD(*marray);
3715 pmask >>= 1;
3716 if (!pmask) pmask = 0x8000;
3718 } /* for(x = 0; x < msg->width; x++) */
3719 break;
3721 case 2: /* COMPLEMENT */
3722 for(x = 0; x < msg->width; x++)
3724 if (!maskarray || (maskword & mmask))
3726 if (patword & pmask) xbuf[x] = ~xbuf[x];
3729 if (maskarray)
3731 mmask >>= 1;
3732 if (!mmask)
3734 mmask = 0x8000;
3735 marray++;
3736 maskword = AROS_BE2WORD(*marray);
3740 pmask >>= 1;
3741 if (!pmask) pmask = 0x8000;
3743 } /* for(x = 0; x < msg->width; x++) */
3744 break;
3746 case 3: /* COMPLEMENT | INVERSVID*/
3747 for(x = 0; x < msg->width; x++)
3749 if (!maskarray || (maskword & mmask))
3751 if (!(patword & pmask)) xbuf[x] = ~xbuf[x];
3754 if (maskarray)
3756 mmask >>= 1;
3757 if (!mmask)
3759 mmask = 0x8000;
3760 marray++;
3761 maskword = AROS_BE2WORD(*marray);
3765 pmask >>= 1;
3766 if (!pmask) pmask = 0x8000;
3768 } /* for(x = 0; x < msg->width; x++) */
3769 break;
3771 case 4: /* JAM2 */
3772 for(x = 0; x < msg->width; x++)
3774 if (!maskarray || (maskword & mmask))
3776 xbuf[x] = (patword & pmask) ? fg : bg;
3779 if (maskarray)
3781 mmask >>= 1;
3782 if (!mmask)
3784 mmask = 0x8000;
3785 marray++;
3786 maskword = AROS_BE2WORD(*marray);
3790 pmask >>= 1;
3791 if (!pmask) pmask = 0x8000;
3793 } /* for(x = 0; x < msg->width; x++) */
3794 break;
3796 case 5: /* JAM2 | INVERSVID */
3797 for(x = 0; x < msg->width; x++)
3799 if (!maskarray || (maskword & mmask))
3801 xbuf[x] = (patword & pmask) ? bg : fg;
3804 if (maskarray)
3806 mmask >>= 1;
3807 if (!mmask)
3809 mmask = 0x8000;
3810 marray++;
3811 maskword = AROS_BE2WORD(*marray);
3815 pmask >>= 1;
3816 if (!pmask) pmask = 0x8000;
3818 } /* for(x = 0; x < msg->width; x++) */
3819 break;
3821 case 6: /* multi color pattern */
3822 for(x = 0; x < msg->width; x++)
3824 if (!maskarray || (maskword & mmask))
3826 WORD plane;
3827 ULONG pixel = (patword & pmask) ? 1 : 0;
3829 for(plane = 1; plane < msg->patterndepth; plane++)
3831 UWORD *_parray = parray + plane * msg->patternheight;
3832 UWORD _patword = AROS_BE2WORD(*_parray);
3834 if (_patword & pmask) pixel |= 1L << plane;
3837 if (msg->patternlut) pixel = msg->patternlut->pixels[pixel];
3839 xbuf[x] = pixel;
3842 if (maskarray)
3844 mmask >>= 1;
3845 if (!mmask)
3847 mmask = 0x8000;
3848 marray++;
3849 maskword = AROS_BE2WORD(*marray);
3853 pmask >>= 1;
3854 if (!pmask) pmask = 0x8000;
3856 } /* for(x = 0; x < msg->width; x++) */
3857 break;
3859 } /* switch(type) */
3861 if (PIXBUF_TIME_TO_END_PROCESS)
3863 LONG height = PIXBUF_LINES_TO_PROCESS;
3865 //kprintf(" PutImage at %d height %d __height %d __bufy %d __worky %d\n",
3866 // y - height + 1 - msg->y, height, __height, __bufy, __worky);
3868 HIDD_BM_PutImage(o,
3869 msg->gc,
3870 (UBYTE *)buf,
3871 msg->width * sizeof(ULONG),
3872 msg->x,
3873 y - height + 1,
3874 msg->width,
3875 height,
3876 vHidd_StdPixFmt_Native32);
3877 xbuf = buf;
3879 else
3881 xbuf += msg->width;
3884 if (maskarray) maskarray += msg->maskmodulo;
3886 PIXBUF_NEXT_LINE;
3888 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
3890 GC_DRMD(msg->gc) = old_drmd;
3892 PIXBUF_FREE(buf);
3894 } /* if (buf) */
3895 else
3900 ReturnVoid("BitMap::PutPattern");
3903 /*****************************************************************************************
3905 NAME
3906 moHidd_BitMap_PutImageLUT
3908 SYNOPSIS
3909 VOID OOP_DoMethod(OOP_Object *o, struct pHidd_BitMap_PutImageLUT *msg);
3911 VOID HIDD_BM_PutImageLUT (OOP_Object *obj, OOP_Object *gc, UBYTE *pixels, ULONG modulo,
3912 WORD x, WORD y, WORD width, WORD height, HIDDT_PixelLUT *pixlut);
3914 LOCATION
3915 hidd.graphics.bitmap
3917 FUNCTION
3919 INPUTS
3920 obj -
3921 gc -
3922 pixels -
3923 modulo -
3924 x, y -
3925 width -
3926 height -
3927 pixlut -
3929 RESULT
3931 NOTES
3933 EXAMPLE
3935 BUGS
3937 SEE ALSO
3939 INTERNALS
3941 *****************************************************************************************/
3943 VOID BM__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o,
3944 struct pHidd_BitMap_PutImageLUT *msg)
3946 WORD x, y;
3947 UBYTE *pixarray = (UBYTE *)msg->pixels;
3948 HIDDT_PixelLUT *pixlut = msg->pixlut;
3949 HIDDT_Pixel *lut = pixlut ? pixlut->pixels : NULL;
3950 HIDDT_Pixel *linebuf;
3951 OOP_Object *gc = msg->gc;
3953 EnterFunc(bug("BitMap::PutImageLUT(x=%d, y=%d, width=%d, height=%d)\n"
3954 , msg->x, msg->y, msg->width, msg->height));
3956 if (msg->width <= 0 || msg->height <= 0)
3957 return;
3959 linebuf = AllocVec(msg->width * sizeof(HIDDT_Pixel), MEMF_PUBLIC);
3961 for(y = 0; y < msg->height; y++)
3963 if (linebuf)
3965 if (lut)
3967 for(x = 0; x < msg->width; x++)
3969 linebuf[x] = lut[pixarray[x]];
3972 else
3974 for(x = 0; x < msg->width; x++)
3976 linebuf[x] = pixarray[x];
3979 pixarray += msg->modulo;
3981 HIDD_BM_PutImage(o,
3982 msg->gc,
3983 (UBYTE *)linebuf,
3985 msg->x,
3986 msg->y + y,
3987 msg->width,
3989 vHidd_StdPixFmt_Native32);
3991 } /* if (linebuf) */
3992 else
3994 ULONG old_fg;
3996 /* Preserve old fg pen */
3997 old_fg = GC_FG(gc);
3999 if (lut)
4001 for(x = 0; x < msg->width; x++)
4003 GC_FG(gc) = lut[pixarray[x]];
4004 HIDD_BM_DrawPixel(o, gc, msg->x + x, msg->y + y);
4007 else
4009 for(x = 0; x < msg->width; x++)
4011 GC_FG(gc) = pixarray[x];
4012 HIDD_BM_DrawPixel(o, gc, msg->x + x, msg->y + y);
4015 GC_FG(gc) = old_fg;
4017 pixarray += msg->modulo;
4019 } /* if (linebuf) else ... */
4021 } /* for(y = 0; y < msg->height; y++) */
4023 FreeVec(linebuf);
4025 ReturnVoid("BitMap::PutImageLUT");
4027 /*****************************************************************************************
4029 NAME
4030 moHidd_BitMap_PutTranspImageLUT
4032 SYNOPSIS
4033 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_PutTranspImageLUT *msg);
4035 VOID HIDD_BM_PutTranspImageLUT (OOP_Object *obj, OOP_Object *gc, UBYTE *pixels,
4036 ULONG modulo, WORD x, WORD y, WORD width, WORD height,
4037 HIDDT_PixelLUT *pixlut, UBYTE transparent);
4039 LOCATION
4040 hidd.graphics.bitmap
4042 FUNCTION
4043 Copy an array of 8-bit LUT pixels to the bitmap at the specified position making
4044 one of colors transparent.
4046 Pixels are converted to bitmap's native format using either user-supplied LUT (if
4047 given) or bitmap's own colormap.
4049 Draw mode of the supplied GC is ignored, the operation is always bulk copy.
4051 INPUTS
4052 obj - A bitmap to draw image on
4053 gc - A GC used for drawing
4054 pixels - A pointer to source pixel array
4055 modulo - Total number of bytes per line in the source array
4056 x, y - Top-left corner of the destination rectangle
4057 width - Width of the image to draw
4058 height - Height of the image to draw
4059 pixlut - An optional pointer to a LUT to use. NULL means using bitmap's
4060 own colormap (if available)
4061 transparent - Value of pixels in the source array which will be made
4062 transparent
4064 RESULT
4065 None
4067 NOTES
4069 EXAMPLE
4071 BUGS
4073 SEE ALSO
4075 INTERNALS
4077 *****************************************************************************************/
4079 VOID BM__Hidd_BitMap__PutTranspImageLUT(OOP_Class *cl, OOP_Object *o,
4080 struct pHidd_BitMap_PutTranspImageLUT *msg)
4082 WORD x, y;
4083 UBYTE *pixarray = (UBYTE *)msg->pixels;
4084 UBYTE transparent = msg->transparent;
4085 HIDDT_PixelLUT *pixlut = msg->pixlut;
4086 HIDDT_Pixel *lut = pixlut ? pixlut->pixels : NULL;
4087 HIDDT_Pixel *buf, *xbuf;
4088 struct HIDDBitMapData *data;
4089 PIXBUF_DECLARE_VARS
4091 data = OOP_INST_DATA(cl, o);
4093 EnterFunc(bug("BitMap::PutTranspImageLUT(x=%d, y=%d, width=%d, height=%d)\n"
4094 , msg->x, msg->y, msg->width, msg->height));
4096 if (msg->width <= 0 || msg->height <= 0)
4097 return;
4099 PIXBUF_ALLOC(buf, msg->width * sizeof(HIDDT_Pixel), msg->height);
4101 if (buf)
4103 HIDDT_DrawMode old_drmd = GC_DRMD(msg->gc);
4105 GC_DRMD(msg->gc) = vHidd_GC_DrawMode_Copy;
4106 xbuf = buf;
4108 for(y = msg->y; y < msg->y + msg->height; y++)
4110 if (PIXBUF_TIME_TO_START_PROCESS)
4112 WORD height = PIXBUF_LINES_TO_PROCESS;
4114 HIDD_BM_GetImage(o,
4115 (UBYTE *)buf,
4116 msg->width * sizeof(HIDDT_Pixel),
4117 msg->x,
4119 msg->width,
4120 height,
4121 vHidd_StdPixFmt_Native32);
4124 if (lut)
4126 for(x = 0; x < msg->width; x++)
4128 UBYTE pix = *pixarray++;
4130 if (pix != transparent)
4132 xbuf[x] = lut[pix];
4135 } /* for(x = 0; x < msg->width; x++) */
4137 else
4139 for(x = 0; x < msg->width; x++)
4141 UBYTE pix = *pixarray++;
4143 if (pix != transparent)
4145 if (data->colmap)
4146 pix = HIDD_CM_GetPixel(data->colmap, pix);
4147 xbuf[x] = pix;
4150 } /* for(x = 0; x < msg->width; x++) */
4154 if (PIXBUF_TIME_TO_END_PROCESS)
4156 LONG height = PIXBUF_LINES_TO_PROCESS;
4158 HIDD_BM_PutImage(o,
4159 msg->gc,
4160 (UBYTE *)buf,
4161 msg->width * sizeof(HIDDT_Pixel),
4162 msg->x,
4163 y - height + 1,
4164 msg->width,
4165 height,
4166 vHidd_StdPixFmt_Native32);
4167 xbuf = buf;
4169 else
4171 xbuf += msg->width;
4174 pixarray = ((UBYTE *)pixarray + msg->modulo - msg->width);
4176 PIXBUF_NEXT_LINE;
4179 } /* for(y = msg->y; y < msg->y + msg->height; y++) */
4181 GC_DRMD(msg->gc) = old_drmd;
4183 PIXBUF_FREE(buf);
4185 } /* if (buf) */
4187 ReturnVoid("BitMap::PutTranspImageLUT");
4190 /*****************************************************************************************
4192 NAME
4193 moHidd_BitMap_GetImageLUT
4195 SYNOPSIS
4196 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_GetImageLUT *msg);
4198 VOID HIDD_BM_GetImageLUT (OOP_Object *obj, UBYTE *pixels, ULONG modulo, WORD x, WORD y,
4199 WORD width, WORD height, HIDDT_PixelLUT *pixlut);
4201 LOCATION
4202 hidd.graphics.bitmap
4204 FUNCTION
4206 INPUTS
4207 obj -
4208 pixels -
4209 modulo -
4210 x, y -
4211 width -
4212 height -
4213 pixlut -
4215 RESULT
4217 NOTES
4219 EXAMPLE
4221 BUGS
4223 SEE ALSO
4225 INTERNALS
4227 *****************************************************************************************/
4229 VOID BM__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o,
4230 struct pHidd_BitMap_GetImageLUT *msg)
4232 WORD x, y;
4233 UBYTE *pixarray = (UBYTE *)msg->pixels;
4234 HIDDT_PixelLUT *pixlut = msg->pixlut;
4235 HIDDT_Pixel *lut = pixlut ? pixlut->pixels : NULL;
4236 HIDDT_Pixel *linebuf;
4238 EnterFunc(bug("BitMap::GetImageLUT(x=%d, y=%d, width=%d, height=%d)\n"
4239 , msg->x, msg->y, msg->width, msg->height));
4241 linebuf = AllocVec(msg->width * sizeof(HIDDT_Pixel), MEMF_PUBLIC);
4243 for(y = 0; y < msg->height; y++)
4245 if (linebuf)
4247 HIDD_BM_GetImage(o,
4248 (UBYTE *)linebuf,
4250 msg->x,
4251 msg->y + y,
4252 msg->width,
4254 vHidd_StdPixFmt_Native32);
4255 if (lut)
4257 /* FIXME: This is wrong, but HIDD_BM_GetImageLUT on hi/truecolor screens does not really make sense anyway */
4258 for(x = 0; x < msg->width; x++)
4260 pixarray[x] = (UBYTE)linebuf[x];
4263 else
4265 for(x = 0; x < msg->width; x++)
4267 pixarray[x] = (UBYTE)linebuf[x];
4270 pixarray += msg->modulo;
4272 } /* if (linebuf) */
4273 else
4275 if (lut)
4277 /* FIXME: This is wrong, but HIDD_BM_GetImageLUT on hi/truecolor screens does not really make sense anyway */
4278 for(x = 0; x < msg->width; x++)
4280 pixarray[x] = (UBYTE)HIDD_BM_GetPixel(o, msg->x + x, msg->y + y);
4283 else
4285 for(x = 0; x < msg->width; x++)
4287 pixarray[x] = (UBYTE)HIDD_BM_GetPixel(o, msg->x + x, msg->y + y);
4291 pixarray += msg->modulo;
4293 } /* if (linebuf) else ... */
4295 } /* for(y = 0; y < msg->height; y++) */
4297 if (linebuf) FreeVec(linebuf);
4299 ReturnVoid("BitMap::GetImageLUT");
4302 /*****************************************************************************************
4304 NAME
4305 moHidd_BitMap_BlitColorExpansion
4307 SYNOPSIS
4308 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_BlitColorExpansion *msg);
4310 VOID HIDD_BM_BlitColorExpansion (OOP_Object *obj, OOP_Object *gc, OOP_Object *srcBitMap,
4311 WORD srcX, WORD srcY, WORD destX, WORD destY,
4312 UWORD width, UWORD height);
4314 LOCATION
4315 hidd.graphics.bitmap
4317 FUNCTION
4318 Perform a color expansion of the mask in srcBitMap according to foreground and background
4319 colors and expansion mode specified by the supplied GC. Pixels which are set to zero in
4320 the mask bitmap will be either painted by background (in opaque mode) or left without
4321 change (in transparent mode). Pixels which are set to nonzero in the mask will be painted
4322 by foreground color.
4324 The result of expansion is blitted onto the destination bitmap accorging to GC's draw mode.
4326 INPUTS
4327 obj - A bitmap to draw on
4328 gc - A GC object to use for drawing
4329 srcBitMap - A bitmap object containing mask image.
4330 srcX, srcY - A top-left coordinate of the used rectangle in the source bitmap
4331 destX, destY - A top-left coordinate of the destination rectangle to draw in
4332 width, height - A size of the rectangle to blit
4334 RESULT
4335 None.
4337 NOTES
4338 This method was previously used by graphics.library/Text() to draw fonts with no
4339 styles specified. Currently graphics.library always uses BltTemplate() and this
4340 method is considered obsolete.
4342 EXAMPLE
4344 BUGS
4346 SEE ALSO
4348 INTERNALS
4350 *****************************************************************************************/
4352 VOID BM__Hidd_BitMap__BlitColorExpansion(OOP_Class *cl, OOP_Object *o,
4353 struct pHidd_BitMap_BlitColorExpansion *msg)
4355 #ifdef __RESERVED__
4356 ULONG cemd;
4357 ULONG fg, bg;
4358 LONG x, y;
4360 OOP_Object *gc = msg->gc;
4362 EnterFunc(bug("BitMap::BlitColorExpansion(srcBM=%p, srcX=%d, srcY=%d, destX=%d, destY=%d, width=%d, height=%d)\n",
4363 msg->srcBitMap, msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height));
4365 cemd = GC_COLEXP(gc);
4366 fg = GC_FG(gc);
4367 bg = GC_BG(gc);
4369 /* bug("------------- Blit_ColExp: (%d, %d, %d, %d, %d, %d) cemd=%d, fg=%p, bg=%p -------------\n"
4370 , msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height
4371 , cemd, fg, bg);
4373 for (y = 0; y < msg->height; y ++)
4375 for (x = 0; x < msg->width; x ++)
4377 ULONG is_set;
4379 /* Pixel value is either 0 or 1 for BM of depth 1 */
4380 is_set = HIDD_BM_GetPixel(msg->srcBitMap, x + msg->srcX, y + msg->srcY);
4383 if (is_set)
4384 bug("#");
4385 else
4386 bug(" ");
4388 if (is_set)
4390 HIDD_BM_DrawPixel(o, gc, x + msg->destX, y + msg->destY);
4392 else
4394 if (cemd & vHidd_GC_ColExp_Opaque)
4396 /* Write bixel with BG pen */
4397 GC_FG(gc) = bg;
4398 HIDD_BM_DrawPixel(o, gc, x + msg->destX, y + msg->destY);
4399 /* Reset to FG pen */
4400 GC_FG(gc) = fg;
4403 } /* if () */
4405 } /* for (each x) */
4407 bug("\n");
4409 } /* for ( each y ) */
4410 #endif
4412 ReturnVoid("BitMap::BlitColorExpansion");
4415 /*****************************************************************************************
4417 NAME
4418 moHidd_BitMap_BytesPerLine
4420 SYNOPSIS
4421 ULONG OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_BytesPerLine *msg);
4423 ULONG HIDD_BM_BytesPerLine(OOP_Object *obj, HIDDT_StdPixFmt pixFmt, ULONG width);
4425 LOCATION
4426 hidd.graphics.bitmap
4428 FUNCTION
4429 This method is currently not used and reserved.
4431 INPUTS
4432 obj -
4433 pixFmt -
4434 width -
4436 RESULT
4438 NOTES
4440 EXAMPLE
4442 BUGS
4444 SEE ALSO
4446 INTERNALS
4448 *****************************************************************************************/
4450 ULONG BM__Hidd_BitMap__BytesPerLine(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_BytesPerLine *msg)
4452 #ifdef __RESERVED__
4453 ULONG bpl;
4455 switch (msg->pixFmt)
4457 case vHidd_StdPixFmt_Native32:
4458 bpl = sizeof (HIDDT_Pixel) * msg->width;
4459 break;
4461 case vHidd_StdPixFmt_Native:
4463 struct HIDDBitMapData *data;
4465 data = OOP_INST_DATA(cl, o);
4467 bpl = ((HIDDT_PixelFormat *)data->prot.pixfmt)->bytes_per_pixel * msg->width;
4468 break;
4471 default:
4473 OOP_Object *pf;
4474 struct HIDDBitMapData *data;
4476 data = OOP_INST_DATA(cl, o);
4478 pf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
4480 if (NULL == pf)
4482 D(bug("!!! COULD NOT GET STD PIXFMT IN BitMap::BytesPerLine() !!!\n"));
4483 return 0;
4486 bpl = ((HIDDT_PixelFormat *)pf)->bytes_per_pixel * msg->width;
4487 break;
4491 return bpl;
4492 #else
4493 return 0;
4494 #endif
4498 /****************************************************************************************/
4501 This makes it easier to create a subclass of the graphics hidd.
4502 It is only allowed to use this method in the p_RootNew method of a
4503 bitmap subclass.
4506 /****************************************************************************************/
4508 VOID BM__Root__Set(OOP_Class *cl, OOP_Object *obj, struct pRoot_Set *msg)
4510 struct HIDDBitMapData *data = OOP_INST_DATA(cl, obj);
4511 struct TagItem *tag;
4512 const struct TagItem *tstate;
4513 ULONG idx;
4515 /* EnterFunc(bug("BitMap::Set()\n"));
4517 tstate = msg->attrList;
4518 while((tag = NextTagItem(&tstate)))
4520 if(IS_BITMAP_ATTR(tag->ti_Tag, idx))
4522 switch(idx)
4524 case aoHidd_BitMap_Width:
4525 data->width = tag->ti_Data;
4526 break;
4528 case aoHidd_BitMap_Height:
4529 data->height = tag->ti_Data;
4530 break;
4532 case aoHidd_BitMap_Depth:
4533 data->reqdepth = tag->ti_Data;
4534 break;
4536 #if 0
4537 case aoHidd_BitMap_ColorTab:
4538 data->colorTab = (APTR)tag->ti_Data;
4539 break;
4540 #endif
4542 default:
4543 D(bug("!!! TRYING TO SET NONSETTABLE BITMAP ATTR %d !!!\n", idx));
4544 break;
4550 return;
4553 /*****************************************************************************************
4555 NAME
4556 moHidd_BitMap_SetColorMap
4558 SYNOPSIS
4559 OOP_Object * OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_SetColorMap *msg);
4561 OOP_Object * HIDD_BM_SetColorMap(OOP_Object *obj, OOP_Object *colorMap);
4563 LOCATION
4564 hidd.graphics.bitmap
4566 FUNCTION
4568 INPUTS
4569 obj -
4570 colorMap -
4572 RESULT
4574 NOTES
4576 EXAMPLE
4578 BUGS
4580 SEE ALSO
4582 INTERNALS
4584 *****************************************************************************************/
4586 OOP_Object *BM__Hidd_BitMap__SetColorMap(OOP_Class *cl, OOP_Object *o,
4587 struct pHidd_BitMap_SetColorMap *msg)
4589 struct HIDDBitMapData *data;
4590 OOP_Object *old;
4592 data = OOP_INST_DATA(cl, o);
4594 old = data->colmap;
4595 data->colmap = msg->colorMap;
4597 return old;
4600 /*****************************************************************************************
4602 NAME
4603 moHidd_BitMap_MapColor
4605 SYNOPSIS
4606 HIDDT_Pixel OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_MapColor *msg);
4608 HIDDT_Pixel HIDD_BM_MapColor(OOP_Object *obj, HIDDT_Color *color);
4610 LOCATION
4611 hidd.graphics.bitmap
4613 FUNCTION
4615 INPUTS
4616 obj -
4617 color -
4619 RESULT
4621 NOTES
4623 EXAMPLE
4625 BUGS
4627 SEE ALSO
4629 INTERNALS
4631 *****************************************************************************************/
4633 /* We only care about magnitudes here, so we don't
4634 * have to perform the square root operation to get
4635 * the real distance.
4637 static ULONG colorDistance(HIDDT_Color *a, HIDDT_Color *b)
4639 #define SQR(x) ((x) * (x))
4640 return SQR((int)a->red - (int)b->red) +
4641 SQR((int)a->blue - (int)b->blue) +
4642 SQR((int)a->green - (int)b->green) +
4643 SQR((int)a->alpha - (int)b->alpha);
4644 #undef SQR
4647 HIDDT_Pixel BM__Hidd_BitMap__MapColor(OOP_Class *cl, OOP_Object *o,
4648 struct pHidd_BitMap_MapColor *msg)
4650 HIDDT_PixelFormat *pf = BM_PIXFMT(o);
4652 HIDDT_Pixel red = msg->color->red;
4653 HIDDT_Pixel green = msg->color->green;
4654 HIDDT_Pixel blue = msg->color->blue;
4655 HIDDT_Pixel alpha = msg->color->alpha;
4657 /* This code assumes that sizeof(HIDDT_Pixel) is a multiple of sizeof(col->#?),
4658 which should be true for most (all?) systems. I have never heard
4659 of any system with for example 3 byte types.
4662 if (IS_TRUECOLOR(pf))
4664 if (HIDD_PF_SWAPPIXELBYTES(pf))
4666 /* FIXME: BM__Hidd_BitMap__MapColor assuming that SwapPixelBytes flag only set for 2-byte/16-bit pixel formats */
4668 HIDDT_Pixel pixel = MAP_RGBA(red, green, blue, alpha, pf);
4670 msg->color->pixval = SWAPBYTES_WORD(pixel);
4672 else
4674 msg->color->pixval = MAP_RGBA(red, green, blue, alpha, pf);
4677 else
4679 struct HIDDBitMapData *data = OOP_INST_DATA(cl, o);
4680 HIDDT_Color *ctab;
4681 HIDDT_ColorLUT *cmap;
4682 ULONG i;
4683 ULONG best_ndx = ~0, best_dist = ~0;
4685 cmap = (HIDDT_ColorLUT *)data->colmap;
4686 ctab = cmap->colors;
4687 /* Search for the best match in the color table */
4688 for (i = 0; i < cmap->entries; i++) {
4689 ULONG dist;
4691 dist = colorDistance(&ctab[i], msg->color);
4692 if (dist < best_dist) {
4693 best_dist = dist;
4694 best_ndx = i;
4698 if (best_dist != ~0)
4699 msg->color->pixval = ctab[best_ndx].pixval;
4702 return msg->color->pixval;
4705 /*****************************************************************************************
4707 NAME
4708 moHidd_BitMap_UnmapPixel
4710 SYNOPSIS
4711 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_UnmapPixel *msg);
4713 VOID HIDD_BM_UnmapPixel(OOP_Object *obj, HIDDT_Pixel pixel, HIDDT_Color *color);
4715 LOCATION
4716 hidd.graphics.bitmap
4718 FUNCTION
4720 INPUTS
4721 obj -
4722 pixel -
4723 color -
4725 RESULT
4727 NOTES
4729 EXAMPLE
4731 BUGS
4733 SEE ALSO
4735 INTERNALS
4737 *****************************************************************************************/
4739 VOID BM__Hidd_BitMap__UnmapPixel(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UnmapPixel *msg)
4742 HIDDT_PixelFormat *pf = BM_PIXFMT(o);
4744 if (IS_TRUECOLOR(pf))
4746 HIDDT_Pixel pixel = msg->pixel;
4748 if (HIDD_PF_SWAPPIXELBYTES(pf))
4750 /* FIXME: bitmap_unmappixel assuming that SwapPixelBytes flag only set for 2-byte/16-bit pixel formats */
4751 pixel = SWAPBYTES_WORD(pixel);
4754 msg->color->red = RED_COMP (pixel, pf);
4755 msg->color->green = GREEN_COMP (pixel, pf);
4756 msg->color->blue = BLUE_COMP (pixel, pf);
4757 msg->color->alpha = ALPHA_COMP (pixel, pf);
4759 else
4761 struct HIDDBitMapData *data = OOP_INST_DATA(cl, o);
4762 HIDDT_ColorLUT *clut;
4764 clut = (HIDDT_ColorLUT *)data->colmap;
4768 /* FIXME: Use CLUT shift and CLUT mask here */
4769 if (msg->pixel < 0 || msg->pixel >= clut->entries)
4770 return;
4772 *msg->color = clut->colors[msg->pixel];
4776 /* Unnecessary, but... */
4777 msg->color->pixval = msg->pixel;
4780 /*****************************************************************************************
4782 NAME
4783 moHidd_BitMap_ObtainDirectAccess
4785 SYNOPSIS
4786 BOOL OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_ObtainDirectAccess *msg);
4788 BOOL HIDD_BM_ObtainDirectAccess(OOP_Object *obj, UBYTE **addressReturn,
4789 ULONG *widthReturn, ULONG *heightReturn,
4790 ULONG *bankSizeReturn, ULONG *memSizeReturn);
4792 LOCATION
4793 hidd.graphics.bitmap
4795 FUNCTION
4797 INPUTS
4798 obj -
4799 addressReturn -
4800 widthReturn -
4801 heightReturn -
4802 bankSizeReturn -
4803 memSizeReturn -
4805 RESULT
4806 BOOL
4808 NOTES
4810 EXAMPLE
4812 BUGS
4814 SEE ALSO
4816 INTERNALS
4818 *****************************************************************************************/
4820 BOOL BM__Hidd_BitMap__ObtainDirectAccess(OOP_Class *cl, OOP_Object *o,
4821 struct pHidd_BitMap_ObtainDirectAccess *msg)
4823 /* Default implementation of direct access funcs. Just return FALSE */
4824 return FALSE;
4827 /*****************************************************************************************
4829 NAME
4830 moHidd_BitMap_ReleaseDirectAccess
4832 SYNOPSIS
4833 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_ReleaseDirectAccess *msg);
4835 VOID HIDD_BM_ReleaseDirectAccess(OOP_Object *obj);
4837 LOCATION
4838 hidd.graphics.bitmap
4840 FUNCTION
4842 INPUTS
4843 obj -
4845 RESULT
4847 NOTES
4849 EXAMPLE
4851 BUGS
4853 SEE ALSO
4855 INTERNALS
4857 *****************************************************************************************/
4859 VOID BM__Hidd_BitMap__ReleaseDirectAccess(OOP_Class *cl, OOP_Object *o,
4860 struct pHidd_BitMap_ReleaseDirectAccess *msg)
4862 D(bug("!!! BitMap BaseClasse ReleaseDirectAccess() called !!!\n"));
4863 D(bug("!!! This should never happen and is probably due to a buggy implementation in the subclass !!!\n"));
4865 return;
4868 /*****************************************************************************************
4870 NAME
4871 moHidd_BitMap_BitMapScale
4873 SYNOPSIS
4874 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_BitMapScale * msg);
4876 VOID HIDD_BM_BitMapScale(OOP_Object *obj, OOP_Object *src, OOP_Object *dest,
4877 struct BitScaleArgs * bsa, OOP_Object *gc);
4879 LOCATION
4880 hidd.graphics.bitmap
4882 FUNCTION
4884 INPUTS
4885 obj -
4886 src -
4887 dest -
4888 bsa -
4889 gc -
4891 RESULT
4893 NOTES
4895 EXAMPLE
4897 BUGS
4899 SEE ALSO
4901 INTERNALS
4903 *****************************************************************************************/
4905 VOID BM__Hidd_BitMap__BitMapScale(OOP_Class * cl, OOP_Object *o,
4906 struct pHidd_BitMap_BitMapScale * msg)
4908 struct BitScaleArgs *bsa = msg->bsa;
4909 ULONG *srcbuf, *dstbuf;
4910 LONG srcline = -1;
4911 UWORD *linepattern;
4912 ULONG count;
4913 UWORD ys = bsa->bsa_SrcY;
4914 ULONG xs = bsa->bsa_SrcX;
4915 ULONG dyd = bsa->bsa_DestHeight;
4916 ULONG dxd = bsa->bsa_DestWidth;
4917 LONG accuys = dyd;
4918 LONG accuxs = dxd;
4919 ULONG dxs = bsa->bsa_SrcWidth;
4920 ULONG dys = bsa->bsa_SrcHeight;
4921 LONG accuyd = - (dys >> 1);
4922 LONG accuxd = - (dxs >> 1);
4923 ULONG x;
4925 if ((srcbuf = AllocVec(bsa->bsa_SrcWidth * sizeof(ULONG), 0)) == NULL)
4926 return;
4928 if ((dstbuf = AllocVec(bsa->bsa_DestWidth * sizeof(ULONG), 0)) == NULL) {
4929 FreeVec(srcbuf);
4930 return;
4933 if ((linepattern = (UWORD *) AllocVec(bsa->bsa_DestWidth * sizeof(UWORD), 0)) == NULL) {
4934 FreeVec(dstbuf);
4935 FreeVec(srcbuf);
4936 return;
4939 count = 0;
4940 while (count < bsa->bsa_DestWidth) {
4941 accuxd += dxs;
4942 while (accuxd > accuxs) {
4943 xs++;
4944 accuxs += dxd;
4947 linepattern[count] = xs;
4949 count++;
4952 count = bsa->bsa_DestY;
4953 while (count < bsa->bsa_DestHeight + bsa->bsa_DestY) {
4954 accuyd += dys;
4955 while (accuyd > accuys) {
4956 ys++;
4957 accuys += dyd;
4960 if (srcline != ys) {
4961 HIDD_BM_GetImage(msg->src, (UBYTE *) srcbuf, bsa->bsa_SrcWidth * sizeof(ULONG), bsa->bsa_SrcX, bsa->bsa_SrcY + ys, bsa->bsa_SrcWidth, 1, vHidd_StdPixFmt_Native32);
4962 srcline = ys;
4964 for (x = 0; x < bsa->bsa_DestWidth; x++)
4965 dstbuf[x] = srcbuf[linepattern[x]];
4968 HIDD_BM_PutImage(msg->dst, msg->gc, (UBYTE *) dstbuf, bsa->bsa_DestWidth * sizeof(ULONG), bsa->bsa_DestX, bsa->bsa_DestY + count, bsa->bsa_DestWidth, 1, vHidd_StdPixFmt_Native32);
4970 count++;
4973 FreeVec(linepattern);
4975 FreeVec(dstbuf);
4976 FreeVec(srcbuf);
4979 /*****************************************************************************************
4981 NAME
4982 moHidd_BitMap_SetRGBConversionFunction
4984 SYNOPSIS
4985 HIDDT_RGBConversionFunction
4986 OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_SetRGBConversionFunction *msg);
4988 HIDDT_RGBConversionFunction
4989 HIDD_BM_SetRGBConversionFunction(OOP_Object *obj, HIDDT_StdPixFmt srcPixFmt,
4990 HIDDT_StdPixFmt dstPixFmt,
4991 HIDDT_RGBConversionFunction function);
4993 LOCATION
4994 hidd.graphics.bitmap
4996 FUNCTION
4998 INPUTS
5000 RESULT
5002 NOTES
5004 EXAMPLE
5006 BUGS
5008 SEE ALSO
5010 INTERNALS
5012 *****************************************************************************************/
5014 HIDDT_RGBConversionFunction BM__Hidd_BitMap__SetRGBConversionFunction(OOP_Class * cl, OOP_Object *o,
5015 struct pHidd_BitMap_SetRGBConversionFunction * msg)
5017 HIDDT_RGBConversionFunction old;
5019 if ((msg->srcPixFmt < FIRST_RGB_STDPIXFMT) ||
5020 (msg->dstPixFmt < FIRST_RGB_STDPIXFMT) ||
5021 (msg->srcPixFmt > LAST_RGB_STDPIXFMT) ||
5022 (msg->dstPixFmt > LAST_RGB_STDPIXFMT))
5024 return (HIDDT_RGBConversionFunction)-1;
5026 else
5028 ObtainSemaphore(&CSD(cl)->rgbconvertfuncs_sem);
5029 old = CSD(cl)->rgbconvertfuncs[msg->srcPixFmt - FIRST_RGB_STDPIXFMT][msg->dstPixFmt - FIRST_RGB_STDPIXFMT];
5030 CSD(cl)->rgbconvertfuncs[msg->srcPixFmt - FIRST_RGB_STDPIXFMT][msg->dstPixFmt - FIRST_RGB_STDPIXFMT] = msg->function;
5031 ReleaseSemaphore(&CSD(cl)->rgbconvertfuncs_sem);
5033 return old;
5037 /*****************************************************************************************
5039 NAME
5040 moHidd_BitMap_UpdateRect
5042 SYNOPSIS
5043 VOID OOP_DoMethod(OOP_Object *obj, struct pHidd_BitMap_UpdateRect *msg);
5045 VOID HIDD_BM_UpdateRect(OOP_Object *obj, WORD x, WORD y, WORD width, WORD height);
5047 LOCATION
5048 hidd.graphics.bitmap
5050 FUNCTION
5051 Update displayed image of the given rectangle.
5053 Some drivers (like VGA and VESA) may work not with VRAM directly, but with a mirrored
5054 copy of it. Usually it is done in case if VRAM reading is slow. This method is called
5055 by the system after it completes any drawing operation, in order to make sure that
5056 changes made are visible on the actual screen. If your driver uses mirroring, this method
5057 should copy the given rectangle (at least) from the mirror buffer to the actual VRAM.
5059 This method is also called after changing currently visible bitmap (after moHidd_Gfx_Show
5060 method call) in order to allow the mirroring driver to refresh the screen after current bitmap
5061 changed. Note that moHidd_Gfx_ShowViewPorts is very different and moHidd_BitMap_UpdateRect
5062 will not be called if it succeeded!
5064 INPUTS
5065 obj - an object whose image to refresh
5066 x, y - A top-left edge of the rectangle to refresh
5067 width - Width of the rectangle to refresh
5068 height - Height of the rectangle to refresh
5070 RESULT
5071 None.
5073 NOTES
5074 This method is called also on offscreen bitmaps. You should track visible state of your bitmap
5075 and ignore these calls if it's not currently visible on the screen.
5077 EXAMPLE
5079 BUGS
5081 SEE ALSO
5083 INTERNALS
5085 *****************************************************************************************/
5087 VOID BM__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UpdateRect *msg) {
5088 /* baseclass version does nothing */
5089 return;
5092 /****************************************************************************************/
5094 /* private ! */
5096 /****************************************************************************************/
5098 BOOL BM__Hidd_BitMap__SetBitMapTags(OOP_Class *cl, OOP_Object *o,
5099 struct pHidd_BitMap_SetBitMapTags *msg)
5101 struct HIDDBitMapData *data;
5102 OOP_Object *pf;
5103 IPTR attrs[num_Hidd_BitMap_Attrs];
5104 DECLARE_ATTRCHECK(bitmap);
5106 data = OOP_INST_DATA(cl, o);
5108 if (0 != OOP_ParseAttrs(msg->bitMapTags
5109 , attrs, num_Hidd_BitMap_Attrs
5110 , &ATTRCHECK(bitmap), HiddBitMapAttrBase))
5112 D(bug("!!! FAILED PARSING IN BitMap::SetBitMapTags !!!\n"));
5113 return FALSE;
5116 if (GOT_BM_ATTR(PixFmtTags))
5118 /* Already a pixfmt registered? */
5120 pf = HIDD_Gfx_RegisterPixFmt(data->gfxhidd, (struct TagItem *)attrs[AO(PixFmtTags)]);
5121 if (NULL == pf)
5122 return FALSE;
5124 if (data->pf_registered)
5125 HIDD_Gfx_ReleasePixFmt(data->gfxhidd, data->prot.pixfmt);
5127 data->prot.pixfmt = pf;
5131 if (GOT_BM_ATTR(Width))
5132 data->width = attrs[AO(Width)];
5134 if (GOT_BM_ATTR(Height))
5135 data->height = attrs[AO(Height)];
5137 if (GOT_BM_ATTR(BytesPerRow))
5138 data->bytesPerRow = attrs[AO(BytesPerRow)];
5140 return TRUE;
5143 /****************************************************************************************/
5145 BOOL HIDD_BitMap_SetBitMapTags(OOP_Object *o, struct TagItem *bitMapTags)
5147 STATIC_MID;
5148 struct pHidd_BitMap_SetBitMapTags p, *msg = &p;
5150 if (!static_mid) static_mid = OOP_GetMethodID(IID_Hidd_BitMap, moHidd_BitMap_SetBitMapTags);
5152 p.mID = static_mid;
5154 p.bitMapTags = bitMapTags;
5156 return (BOOL)OOP_DoMethod(o, (OOP_Msg)msg);
5159 /****************************************************************************************/