
-----------------------------------
lufthansa747
Fri Apr 15, 2011 3:45 pm

Help with drawing images in the backround
-----------------------------------
i am trying to get some extra credit for my computer class and need a bit of help. just so you guys know our class is using the holt soft hsa console to do all the file i/o, text drawing , ect... i have been improving it and adding fetures to make it better. currently i am trying to add the ability to draw an image in the back round and have it stay there. i have gotten the ability to draw the image but the problem is when the text draws over it it begins to erase the image. is there any way to make the white space of the text like inivis? or is there another way to fix the problem

-----------------------------------
lufthansa747
Fri Apr 15, 2011 10:54 pm

Re: Help with drawing images in the backround
-----------------------------------
anyone?

-----------------------------------
Tony
Fri Apr 15, 2011 11:27 pm

RE:Help with drawing images in the backround
-----------------------------------
I imagine that filling in the background is just how text is printed to the screen. There are certain benefits to this, mostly in character replacement applications. You might have to figure out how to draw text yourself, to have transparent backgrounds.

-----------------------------------
DemonWasp
Sat Apr 16, 2011 2:01 am

RE:Help with drawing images in the backround
-----------------------------------
It's possible to achieve this effect (pretty easily too) if you use the Swing API, or even the AWT API. You could even use the SWT API if you gave up on Ready to Program. However, I don't think it's possible on HSA's console.

-----------------------------------
lufthansa747
Sat Apr 16, 2011 1:47 pm

Re: Help with drawing images in the backround
-----------------------------------
i am trying this code but i am getting an error

Exception in thread "main" java.lang.IllegalArgumentException: Number of scaling constants does not equal the number of of color or color/alpha  components
        at java.awt.image.RescaleOp.filter(RescaleOp.java:323)
        at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:1076)
        at sun.java2d.pipe.ValidatePipe.transformImage(ValidatePipe.java:220)
        at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3125)
        at hsa.ConsoleCanvasGraphics.drawImage(ConsoleCanvasGraphics.java:321)
        at hsa.Console.drawImage(Console.java:260)
        at hsa.NewClass.main(NewClass.java:39)

 public synchronized void drawImage (Image img, float rop, int x, int y){
        // First draw the line to the offscreen image.
	Graphics offscreenGraphics = getOffscreenGraphics (Color.black);
	offscreenGraphics.drawImage(img, x, y, null);

	// MacOS X seems to have a problem.  Only repainting seems to work.
	if (macOSX)
	{
	    repaint ();
	    return;
	} // if (macOSX)

        /* Create a rescale filter op that makes the image 50% opaque */
        float


Please help?

-----------------------------------
RandomLetters
Sat Apr 16, 2011 2:18 pm

RE:Help with drawing images in the backround
-----------------------------------
Are you sure you can pass null values into RescaleOp for offsets?  I'm not familiar with RescaleOp.

For text, you could use setBackgroundColor method with a color that has alpha set to 0f, making it transparent.  (I think :P)

-----------------------------------
lufthansa747
Sat Apr 16, 2011 8:13 pm

RE:Help with drawing images in the backround
-----------------------------------
well, i got that rescale code off the java tutorial. and i am trying to draw an image not text

-----------------------------------
RandomLetters
Sun Apr 17, 2011 1:53 pm

RE:Help with drawing images in the backround
-----------------------------------
I don't understand the question then.

Are you trying to:

Load a background image into the window

Draw pictures over the background, but when u erase the pictures, the background still stays?

-----------------------------------
lufthansa747
Sun Apr 17, 2011 3:01 pm

RE:Help with drawing images in the backround
-----------------------------------
ya i bascily want to be able to add a backround image so that text cen be writen to the console and the image will still be visible. but to do this i was trying to draw an image that was transparent.

-----------------------------------
lufthansa747
Sun Apr 17, 2011 4:51 pm

RE:Help with drawing images in the backround
-----------------------------------
?

-----------------------------------
lufthansa747
Mon Apr 18, 2011 1:04 pm

RE:Help with drawing images in the backround
-----------------------------------
?
