1 ;/* compleximage.c - program to show the use of a complex Intuition Image.
2 lc -b1 -cfist -v -y -j73 compleximage.c
3 blink FROM LIB:c.o compleximage.o TO compleximage LIB LIB:lc.lib LIB:amiga.lib
8 Copyright (c) 1992 Commodore-Amiga, Inc.
10 This example is provided in electronic form by Commodore-Amiga, Inc. for
11 use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
12 published by Addison-Wesley (ISBN 0-201-56774-1).
14 The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
15 information on the correct usage of the techniques and operating system
16 functions presented in these examples. The source and executable code
17 of these examples may only be distributed in free electronic form, via
18 bulletin board or as part of a fully non-commercial and freely
19 redistributable diskette. Both the source and executable code (including
20 comments) must be included, without modification, in any copy. This
21 example may not be published in printed form or distributed with any
22 commercial product. However, the programming techniques and support
23 routines set forth in these examples may be used in the development
24 of original executable software products for Commodore Amiga computers.
26 All other rights reserved.
28 This example is provided "as-is" and is subject to change; no
29 warranties are made. All use is at your own risk. No liability or
30 responsibility is assumed.
34 #define INTUI_V36_NAMES_ONLY
36 #include <exec/types.h>
37 #include <intuition/intuition.h>
38 #include <intuition/intuitionbase.h>
40 #include <proto/exec.h>
41 #include <proto/dos.h>
42 #include <proto/intuition.h>
46 static const char version
[] __attribute__((used
)) = "$VER: compleximage 41.1 (14.3.1997)\n";
53 #include <proto/alib.h>
57 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
58 int chkabort(void) { return(0); } /* really */
61 struct IntuitionBase
*IntuitionBase
= NULL
;
63 #define MYIMAGE_LEFT (0)
64 #define MYIMAGE_TOP (0)
65 #define MYIMAGE_WIDTH (24)
66 #define MYIMAGE_HEIGHT (10)
67 #define MYIMAGE_DEPTH (2)
69 /* This is the image data. It is a two bitplane open rectangle which
70 ** is 24 pixels wide and 10 high. Make sure that it is in CHIP memory,
71 ** or allocate a block of chip memory with a call like:
73 ** AllocMem(data_size,MEMF_CHIP)
75 ** and copy the data to that block. See the Exec chapter on
76 ** Memory Allocation for more information on AllocMem().
78 UBYTE __chip myImageData
[] =
80 /* first bitplane of data,
94 /* second bitplane of data,
95 ** filled rectangle to appear within open rectangle.
100 0x00,0xFF, 0x00,0x00,
101 0x00,0xFF, 0x00,0x00,
102 0x00,0xFF, 0x00,0x00,
103 0x00,0xFF, 0x00,0x00,
104 0x00,0x00, 0x00,0x00,
105 0x00,0x00, 0x00,0x00,
106 0x00,0x00, 0x00,0x00,
109 /* used to get the "new look" on a custom screen */
110 UWORD pens
[] = { ~0 };
114 ** main routine. Open required library and window and draw the images.
115 ** This routine opens a very simple window with no IDCMP. See the
116 ** chapters on "Windows" and "Input and Output Methods" for more info.
117 ** Free all resources when done.
119 int main(int argc
, char *argv
[])
123 struct Image myImage
;
125 struct IntuiMessage
*imsg
;
127 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",37);
128 if (IntuitionBase
!= NULL
)
130 if (NULL
!= (scr
= OpenScreenTags(NULL
,
132 SA_Pens
, (IPTR
) &pens
,
136 if (NULL
!= (win
= OpenWindowTags(NULL
,
138 WA_CustomScreen
, (IPTR
) scr
,
139 WA_IDCMP
, IDCMP_RAWKEY
|IDCMP_CLOSEWINDOW
,
141 WA_CloseGadget
, TRUE
,
146 if (NULL
!= (win
= OpenWindowTags(NULL
,
148 WA_CustomScreen
, scr
,
152 myImage
.LeftEdge
= MYIMAGE_LEFT
;
153 myImage
.TopEdge
= MYIMAGE_TOP
;
154 myImage
.Width
= MYIMAGE_WIDTH
;
155 myImage
.Height
= MYIMAGE_HEIGHT
;
156 myImage
.Depth
= MYIMAGE_DEPTH
;
157 myImage
.ImageData
= (UWORD
*)myImageData
;
158 myImage
.PlanePick
= 0x3; /* use first two bitplanes */
159 myImage
.PlaneOnOff
= 0x0; /* clear all unused planes */
160 myImage
.NextImage
= NULL
;
162 /* Draw the image into the first two bitplanes */
163 DrawImage(win
->RPort
,&myImage
,20,50);
165 /* Draw the same image at a new location */
166 DrawImage(win
->RPort
,&myImage
,100,50);
168 /* Change the image to use the second and fourth bitplanes,
169 ** PlanePick is 1010 binary or 0xA,
170 ** and draw it again at a different location
172 myImage
.PlanePick
= 0xA;
173 DrawImage(win
->RPort
,&myImage
,20,100);
175 /* Now set all the bits in the first bitplane with PlaneOnOff.
176 ** This will make all the bits set in the second bitplane
177 ** appear as color 3 (0011 binary), all the bits set in the
178 ** fourth bitplane appear as color 9 (1001 binary) and all
179 ** other pixels will be color 1 (0001 binary. If there were
180 ** any points in the image where both bits were set, they
181 ** would appear as color 11 (1011 binary).
182 ** Draw the image at a different location.
184 myImage
.PlaneOnOff
= 0x1;
185 DrawImage(win
->RPort
,&myImage
,100,50);
190 WaitPort(win
->UserPort
);
192 while ((imsg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
196 case IDCMP_CLOSEWINDOW
:
200 case IDCMP_RAWKEY
: // bug or feature? The program immediately exits
201 // when querying for RAWKEY
202 printf("code %d\n", imsg
->Code
);
208 ReplyMsg((struct Message
*)imsg
);
213 /* Wait a bit, then quit.
214 ** In a real application, this would be an event loop, like the
215 ** one described in the Intuition Input and Output Methods chapter.
224 CloseLibrary((struct Library
*)IntuitionBase
);