pawn@wpi.wpi.edu (Kevin Goroway) (02/19/89)
I am having problems getting an image onto a RastPort (still...) [many many thanks go to Chuck McManis for getting me this far...] DrawImage is now working, but it is not putting my image there, it is putting garbage on the screen... I compile my image data (and the image structure) seperately, using Lattice by doing a: lc -ad b1.c (which supposedly forces my data into chip memory) my code does the following... extern struct Image b1_image; (because I am linking it...) extern UWORD b1_imageData[]; b1_image.ImageData=&b1_imageData[0]; (again actually; this is done also in the structure def.) DrawImage(&rp,&b1_image,10,100); (works (sort of...)) (it is reading my size def fine, but not my image def...) could my image still not be in chip ram? I wrote some code to make sure it is... for (j=0;j<sizeof(b1_imageData);j++) *src++=*dest++; (or something like that, I don't recall) But that didn't work either! Could it have something to do with the PlanePick/PlaneOnOff stuff? (I haven't touched that yet, but I still don't think I should be getting garbage on the screen...) thanks in advance... -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | Pawn@wpi.wpi.edu Worcester Polytechnic Institute, Mass, U.S.A. | | Pawn@wpi.Bitnet main() { printf("Hello World!\n); } | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
groo@dsoft.UUCP (Bill Squier) (01/11/90)
Can any of the UseNet gurus point out to me the error of my ways? The following piece of code attempts to draw a test image into a full screen window with the Intuition function 'DrawImage()', but all I get is a black square the exact size of the image rectangle. I'm almost sure that I have the PlanePick values correct (I've tried 0x1F and 0x0f for this particular 4 bitplane image). Perhaps I'm missing something else? The "hope.h" file which contains the image in included at the end of the source. I'm leaving for school soon, and will temporarily lose access to UseNet, so even a quick reply with no examples will help. If no one can find an error, could someone send me source of a program that uses DrawImage() that WORKS? Thanks in advance. ------------------------------login.c------------------------------------- #include <exec/types.h> #include <intuition/intuition.h> #include <intuition/intuitionbase.h> #include <graphics/gfx.h> #include <graphics/gfxbase.h> #include <stdio.h> #include "hope.h" struct NewScreen loginscreen = { 0, 0, /* left, top */ 640, 200, 4, /* width, height, depth */ 1, 2, /* detail pen, block pen */ HIRES, /* viewmodes */ CUSTOMSCREEN, /* screentype */ NULL, NULL, NULL, NULL }; struct NewWindow plaque_window = { 0, 0, /* left, top */ 640, 200, /* width, height */ 1, 2, /* detail, block */ NULL, /* IDCMP flags */ SIMPLE_REFRESH | BORDERLESS | ACTIVATE | NOCAREREFRESH, NULL, /* gadget */ NULL, /* checkmark */ NULL, /* title */ NULL, /* screen, this has to point to mine later */ NULL, /* bitmap */ 640, 200, /* minimum: width, height */ 640, 200, /* maximum: width, height */ CUSTOMSCREEN /* type */ }; struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; main() { struct RastPort *rp; struct ViewPort *vp; struct Screen *s; struct Window *w; char buf[255]; IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0); if (IntuitionBase == 0) { fprintf(stderr,"login: can't open Intuition, where are we?\n"); exit(1); } GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0); if (GfxBase == 0) { fprintf(stderr,"login: can't open graphics.library\n"); CloseLibrary(IntuitionBase); exit(1); } s = (struct Screen *)OpenScreen(&loginscreen); if (s == NULL) { CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); fprintf(stderr,"login: can't open screen\n"); exit(1); } plaque_window.Screen = s; w = (struct Window *)OpenWindow(&plaque_window); if (w == NULL) { CloseScreen(s); CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); fprintf(stderr,"login: can't open window\n"); exit(1); } rp = w->RPort; vp = &(s->ViewPort); SetScreenColors(vp); SetRast(rp,6); /* clear background */ DrawImage(rp,&Hope,90,10); gets(buf); CloseWindow(w); CloseScreen(s); CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); fprintf(stderr,"I closed nicely.\n"); } ---------------------------end: login.c------------------------------------ ------------------------------hope.h--------------------------------------- /* DragonSoft -- ILBM to C language source code converter */ /* File: test.brush */ #define IMAGEWIDTH 294 #define IMAGEHEIGHT 19 #define IMAGEPLANES 4 /* Image is ByteRun1 encoded. */ /* Image has Transparent Color # 11 */ /* Aspect ratio (X-Y) is 10-11 */ /* Screen size of original image was 640 X 200 */ SetScreenColors(VPort) struct ViewPort *VPort; { SetRGB4(VPort,0,0,0,0); SetRGB4(VPort,1,14,12,10); SetRGB4(VPort,2,12,0,0); SetRGB4(VPort,3,15,6,0); SetRGB4(VPort,4,7,7,7); SetRGB4(VPort,5,9,7,8); SetRGB4(VPort,6,0,5,6); SetRGB4(VPort,7,0,7,8); SetRGB4(VPort,8,15,15,15); SetRGB4(VPort,9,13,13,13); SetRGB4(VPort,10,11,11,11); SetRGB4(VPort,11,9,9,9); SetRGB4(VPort,12,6,6,6); SetRGB4(VPort,13,4,4,4); SetRGB4(VPort,14,2,2,2); SetRGB4(VPort,15,0,0,0); } USHORT ImageBody[] = { /* Actual image date removed was in the order: Plane 0, Plane 1, Plane 2, Plane 3. */ }; struct Image Hope = { 0,0, /* LeftEdge,TopEdge */ 294,19,4, /* Width,Height,Depth */ &ImageBody[0], /* Pointer to Image data */ 0x0F,0x00, /* PlanePick, PlaneOnOff */ NULL, /* Ptr to next image */ }; /* End of ILBM conversion */ --------------------------------end: hope.h------------------------------- -- Bill Squier - Stevens Inst. of Tech | // "Only Amiga makes it possible" Bitnet: u93_wsquier@stevens | \X/ Internet: u93_wsquier@vaxc.stevens-tech.edu Temporary Inet (Please use until Jan. 13): ...uunet!tronsbox!dsoft!groo
mapjilg@gdr.bath.ac.uk (J I L Gold) (01/17/90)
Is your image in chip RAM? If not, that's probably why you get junk. If your C compiler supports it, write struct Image chip Hope = {... or if not, struct Image Hope; struct Image *ChipHope; . . . ChipHope = (struct Image *)AllocMem(sizeof(struct Image), MEMF_CHIP|MEMF_CLEAR); OK? -- -- # J.Gold | mapjilg@uk.ac.bath.gdr # # University of Bath , UK | jilg@uk.ac.bath.maths #
rosenber@ra.abo.fi (Robin Rosenberg INF) (01/19/90)
>Is your image in chip RAM? If not, that's probably why you get junk. >If your C compiler supports it, write > struct Image chip Hope = {... >or if not, That won't help. The Image structure kan be anywhere in cpu accessible memory. The Image data however must be in chip ram. -------------- Robin Rosenberg
peter@cbmvax.commodore.com (Peter Cherna) (01/20/90)
In article <1990Jan17.101103.10084@gdt.bath.ac.uk> mapjilg@gdr.bath.ac.uk (J I L Gold) writes: >Is your image in chip RAM? If not, that's probably why you get junk. Yes on this count. >If your C compiler supports it, write > struct Image chip Hope = {... >or if not, > struct Image Hope; > struct Image *ChipHope; > . > . > . > ChipHope = (struct Image *)AllocMem(sizeof(struct Image), > MEMF_CHIP|MEMF_CLEAR); >OK? Emphatic NOT OK on this count. You've fallen victim to a common misconception. It is not the Image _structure_ itself that needs to be in chip RAM, but the Image _DATA_. So you really want to say UWORD chip myImageData[] = { /* hex uwords describing your image */ }; struct Image myImage = { ..., ..., /* Image LeftEdge and TopEdge */ ..., ..., /* Image Width and Height */ ..., /* Image Depth */ myImageData, /* Pointer to Image Data */ ..., ..., /* Image PlanePick and PlaneOnOff */ ..., /* NextImage (usually NULL) */ }; If your compiler doesn't support the "chip" keyword, then leave out the word "chip" above and say ChipData = (UWORD *)AllocMem(sizeof(ImageData), MEMF_CHIP); if (ChipData) { CopyMem(ImageData, ChipData, sizeof(ImageData)); myImage.ImageData = ChipData; ... } else { /* chip mem allocation failed */ } >-- >-- ># J.Gold | mapjilg@uk.ac.bath.gdr # ># University of Bath , UK | jilg@uk.ac.bath.maths # Peter -- Peter Cherna, Software Engineer, Commodore-Amiga, Inc. {uunet|rutgers}!cbmvax!peter peter@cbmvax.cbm.commodore.com My opinions do not necessarily represent the opinions of my employer.
ridder@elvira.enet.dec.com (Hans Ridder) (01/20/90)
In article <9389@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes: >If your compiler doesn't support the "chip" keyword, then >leave out the word "chip" above and say > > ChipData = (UWORD *)AllocMem(sizeof(ImageData), MEMF_CHIP); > if (ChipData) > { > CopyMem(ImageData, ChipData, sizeof(ImageData)); > myImage.ImageData = ChipData; > ... > } > else > { > /* chip mem allocation failed */ > } In this case, wouldn't be a good idea to use the TypeOfMem() Exec function to determine if the ImageData was was already in chip memory? Something like (I don't have the RKM's here, so no snickering): if ((TypeOfMem(ImageData) & MEMF_CHIP) == 0) { ChipData = (UWORD)AllocMem(sizeof(ImageData), MEMF_CHIP); ... /* All the stuff you had */ } > Peter Cherna, Software Engineer, Commodore-Amiga, Inc. > {uunet|rutgers}!cbmvax!peter peter@cbmvax.cbm.commodore.com -hans ======================================================================== Hans-Gabriel Ridder Digital Equipment Corporation ridder@elvira.enet.dec.com Customer Support Center ...decwrl!elvira.enet!ridder Colorado Springs, CO
peter@cbmvax.cbm.commodore.com.commodore.com (Peter Cherna) (01/23/90)
In article <625@shodha.dec.com> ridder@elvira.enet.dec.com (Hans Ridder) writes: >In article <9389@cbmvax.commodore.com> peter@cbmvax.commodore.com > (Peter Cherna) writes: >>If your compiler doesn't support the "chip" keyword, then >>leave out the word "chip" above and say >> >> ChipData = (UWORD *)AllocMem(sizeof(ImageData), MEMF_CHIP); ... >In this case, wouldn't be a good idea to use the TypeOfMem() Exec >function to determine if the ImageData was was already in chip memory? >Something like (I don't have the RKM's here, so no snickering): > > if ((TypeOfMem(ImageData) & MEMF_CHIP) == 0) { > ChipData = (UWORD)AllocMem(sizeof(ImageData), MEMF_CHIP); > ... /* All the stuff you had */ > } No snickering at all. Very astute observation. > >> Peter Cherna, Software Engineer, Commodore-Amiga, Inc. >> {uunet|rutgers}!cbmvax!peter peter@cbmvax.cbm.commodore.com > >-hans >======================================================================== > Hans-Gabriel Ridder Digital Equipment Corporation > ridder@elvira.enet.dec.com Customer Support Center > ...decwrl!elvira.enet!ridder Colorado Springs, CO Peter