🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #2769

DrawImage() woes. (LONG)

#2769
From: Bill Squier
Date: Thu, 11 Jan 1990 03:01
181 lines
5203 bytes
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
Technical Details
Message-ID: <487@dsoft.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!asuvax!mcdphx!mcdchg!ddsw1!tronsbox!dsoft!groo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!asuvax!mcdphx!mcdchg!ddsw1!tronsbox!dsoft!groo
From: groo@dsoft.UUCP (Bill Squier)
Newsgroups: comp.sys.amiga.tech
Subject: DrawImage() woes. (LONG)
Keywords: DrawImage(), PlanePick, PlaneOnOff
Message-ID: <487@dsoft.UUCP>
Date: 11 Jan 90 03:01:52 GMT
Lines: 181