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 UWORD __chip myImageData
[] =
80 /* first bitplane of data,
94 /* second bitplane of data,
95 ** filled rectangle to appear within open rectangle.
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 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",37);
126 if (IntuitionBase
!= NULL
)
128 if (NULL
!= (scr
= OpenScreenTags(NULL
,
130 SA_Pens
, (IPTR
) &pens
,
134 if (NULL
!= (win
= OpenWindowTags(NULL
,
136 WA_CustomScreen
, (IPTR
) scr
,
137 WA_IDCMP
, IDCMP_RAWKEY
,
140 if (NULL
!= (win
= OpenWindowTags(NULL
,
142 WA_CustomScreen
, scr
,
146 myImage
.LeftEdge
= MYIMAGE_LEFT
;
147 myImage
.TopEdge
= MYIMAGE_TOP
;
148 myImage
.Width
= MYIMAGE_WIDTH
;
149 myImage
.Height
= MYIMAGE_HEIGHT
;
150 myImage
.Depth
= MYIMAGE_DEPTH
;
151 myImage
.ImageData
= myImageData
;
152 myImage
.PlanePick
= 0x3; /* use first two bitplanes */
153 myImage
.PlaneOnOff
= 0x0; /* clear all unused planes */
154 myImage
.NextImage
= NULL
;
156 /* Draw the image into the first two bitplanes */
157 DrawImage(win
->RPort
,&myImage
,10,10);
159 /* Draw the same image at a new location */
160 DrawImage(win
->RPort
,&myImage
,100,10);
162 /* Change the image to use the second and fourth bitplanes,
163 ** PlanePick is 1010 binary or 0xA,
164 ** and draw it again at a different location
166 myImage
.PlanePick
= 0xA;
167 DrawImage(win
->RPort
,&myImage
,10,50);
169 /* Now set all the bits in the first bitplane with PlaneOnOff.
170 ** This will make all the bits set in the second bitplane
171 ** appear as color 3 (0011 binary), all the bits set in the
172 ** fourth bitplane appear as color 9 (1001 binary) and all
173 ** other pixels will be color 1 (0001 binary. If there were
174 ** any points in the image where both bits were set, they
175 ** would appear as color 11 (1011 binary).
176 ** Draw the image at a different location.
178 myImage
.PlaneOnOff
= 0x1;
179 DrawImage(win
->RPort
,&myImage
,100,50);
182 /* Wait for a keypress */
183 Wait (1L << win
->UserPort
->mp_SigBit
);
185 /* Wait a bit, then quit.
186 ** In a real application, this would be an event loop, like the
187 ** one described in the Intuition Input and Output Methods chapter.
196 CloseLibrary((struct Library
*)IntuitionBase
);