added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / demos / simpleimage.c
blob9a055401fb1c7e68e44f6541509080417ea9aa01
1 ;/* simpleimage.c - program to show the use of a simple Intuition Image.
2 lc -b1 -cfist -v -y -j73 simpleimage.c
3 blink FROM LIB:c.o+"simpleimage.o" TO "simpleimage" LIB LIB:lc.lib LIB:amiga.lib
4 quit
5 */
7 /*
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.
33 #define INTUI_V36_NAMES_ONLY
35 #include <exec/types.h>
36 #include <intuition/intuition.h>
37 #include <intuition/intuitionbase.h>
39 #include <proto/exec.h>
40 #include <proto/dos.h>
41 #include <proto/intuition.h>
43 #include <stdio.h>
45 static const char version[] = "$VER: simpleimage 41.1 (14.3.1997)\n";
47 #ifdef __AROS__
48 #ifdef __chip
49 #undef __chip
50 #endif
51 #define __chip
52 #include <proto/alib.h>
53 #endif
55 #ifdef LATTICE
56 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
57 int chkabort(void) { return(0); } /* really */
58 #endif
60 struct IntuitionBase *IntuitionBase = NULL;
62 #define MYIMAGE_LEFT (0)
63 #define MYIMAGE_TOP (0)
64 #define MYIMAGE_WIDTH (24)
65 #define MYIMAGE_HEIGHT (10)
66 #define MYIMAGE_DEPTH (1)
68 /* This is the image data. It is a one bit-plane open rectangle which is 24
69 ** pixels wide and 10 high. Make sure that it is in CHIP memory, or allocate
70 ** a block of chip memory with a call like this: AllocMem(data_size,MEMF_CHIP),
71 ** and then copy the data to that block. See the Exec chapter on Memory
72 ** Allocation for more information on AllocMem().
74 UWORD __chip myImageData[] =
76 0xFFFF, 0xFF00,
77 0xC000, 0x0300,
78 0xC000, 0x0300,
79 0xC000, 0x0300,
80 0xC000, 0x0300,
81 0xC000, 0x0300,
82 0xC000, 0x0300,
83 0xC000, 0x0300,
84 0xC000, 0x0300,
85 0xFFFF, 0xFF00,
89 ** main routine. Open required library and window and draw the images.
90 ** This routine opens a very simple window with no IDCMP. See the
91 ** chapters on "Windows" and "Input and Output Methods" for more info.
92 ** Free all resources when done.
94 int main(int argc, char *argv[])
96 struct Window *win;
97 struct Image myImage;
99 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
100 if (IntuitionBase != NULL)
102 #ifdef __AROS__
103 if (NULL != (win = OpenWindowTags(NULL,
104 WA_Width, 200,
105 WA_Height, 100,
106 WA_RMBTrap, TRUE,
107 WA_IDCMP, IDCMP_RAWKEY,
108 TAG_END)))
109 #else
110 if (NULL != (win = OpenWindowTags(NULL,
111 WA_Width, 200,
112 WA_Height, 100,
113 WA_RMBTrap, TRUE,
114 TAG_END)))
115 #endif
117 myImage.LeftEdge = MYIMAGE_LEFT;
118 myImage.TopEdge = MYIMAGE_TOP;
119 myImage.Width = MYIMAGE_WIDTH;
120 myImage.Height = MYIMAGE_HEIGHT;
121 myImage.Depth = MYIMAGE_DEPTH;
122 myImage.ImageData = myImageData;
123 myImage.PlanePick = 0x1; /* use first bit-plane */
124 myImage.PlaneOnOff = 0x0; /* clear all unused planes */
125 myImage.NextImage = NULL;
127 /* Draw the 1 bit-plane image into the first bit-plane (color 1) */
128 DrawImage(win->RPort,&myImage,10,10);
130 /* Draw the same image at a new location */
131 DrawImage(win->RPort,&myImage,100,10);
133 #ifdef __AROS__
134 /* Wait for a keypress */
135 Wait (1L << win->UserPort->mp_SigBit);
136 #else
137 /* Wait a bit, then quit.
138 ** In a real application, this would be an event loop, like the
139 ** one described in the Intuition Input and Output Methods chapter.
141 Delay(200);
142 #endif
144 CloseWindow(win);
146 CloseLibrary((struct Library *)IntuitionBase);
148 return 0;