Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

getting pixels from an applet area

Thread view: 
Qu?bec - 22 Mar 2004 13:18 GMT
Hi,

                       How can I get the pixels from an applet area that
has been drawed, written over etc?
                       How do I put the pixels in a buffer [w, h]?

                       Lets say the portion of the applet screen  is 0, 0,
200, 100.

Jean

===============
 public void grab(Graphics g, int w, int h) {
   int buffer[] = new int [w * h];
   PixelGrabber grabber =
     new PixelGrabber(g, 0, 0, w, h, buffer, 0, w);
   try {
     grabber.grabPixels();
     for (int y = 0; y < h; y++) {
       int col = 0;
       row--;
       for (int x = 0; x < w; x++) {
        buffer[ (x*h ];
       }
     }
       } catch (Exception e) {e.printStackTrace();}

 }
Qu?bec - 23 Mar 2004 00:19 GMT
Is  the copyArea method in awt.Graphics  a jni or exe class?
I cant find it in the jdk1.1.8 src folder.
Andrew Thompson - 23 Mar 2004 00:52 GMT
On Mon, 22 Mar 2004 18:19:49 -0500, Québec wrote:

> Is  the copyArea method in awt.Graphics  a jni or exe class?

I do not quite understand what you are asking.

Graphics.copyArea() is part of the Graphics class,
it is neither a JNI nor 'exe' class..

My (1.4) docs have no indication of when it
was introduced, though the Graphics class is
listed as being introduced in 1.0.

And.. yes, as I suspected, the following code
compiles against a 1.1 rt.jar..
<sscce>
import java.awt.*;

public class GraphicsTest {
   public static void main(String args[]) {
       Panel p = new Panel();
       Graphics g = p.getGraphics();
       g.copyArea(1,1,2,3,4,4);
   }
}
</sscce>

(shrugs)  Does that clear anything up?

Signature

Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology

Qu?bec - 23 Mar 2004 04:20 GMT
Lets say a Martien dropped some pixels on a canvas. No image was loaded or
came from a graphic context.

How do I get them? I red almost everything on RGB filters,
memoryImageSource, PixelsGrabber, etc.  It seems there is no way to get a
screenshot of an application or applet window.

I was thinking I could find a way by scritinizing:
package java.awt.Graphics;
  public abstract void copyArea(int x, int y, int width, int height,
     int dx, int dy);

                                                           but I know some
classes uses native coding.

Jean
Andrew Thompson - 23 Mar 2004 08:55 GMT
On Mon, 22 Mar 2004 22:20:25 -0500, Québec wrote:

> Lets say a Martien

??

>..dropped some pixels

?????

>..on a canvas. No image was loaded or
> came from a graphic context.
>
> How do I get them?

Once you explain those two bits above
where I put question marks, I might at
least understand the question.

Signature

Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology

Qu?bec - 23 Mar 2004 13:21 GMT
You dont understand ...

Ok.

How do you get pixels from a canvas that are not an image?   How do you get
pixels from a canvas if you cant use getImage().

Lets say it is an applet an the users can draw on it whit the mouse.
Then they click on abutton and the image is copied to the clipboard ( if
this is possible) or grabbed with Pixels Grabber and stored in a buffer.
Lets say there is a class wich does this.
First it create an
emptyImage.createImage(100, 100)
then it
Canvas.copyArea(0,0,100,100) in the emptyImage.

Or else.

There is the createScreenCapture in 1.2 but it would probably not be allowed
by the security manager for an applet as told to me by a guru.

Jean
Andrew Thompson - 23 Mar 2004 13:51 GMT
On Tue, 23 Mar 2004 07:21:10 -0500, Québec wrote:

> How do you get pixels from a canvas that are not an image?   How do you get
> pixels from a canvas if you cant use getImage().

You have strayed out of my area of expertise
on that one, so I'll leave it for others.
I will just add some points about copying..

> Lets say it is an applet an the users can draw on it whit the mouse.
> Then they click on abutton and the image is copied to the clipboard ( if
> this is possible)

It is, but the applet needs to be signed
(* actually I am not positive about that,
most AWT textual components support copy
from the underlying OS functionality, but
to do it programmatically would AFAIU,
require a signed applet)

<snip>
> There is the createScreenCapture in 1.2

Eh?  What Class is that in?

It sounds like the wrong method anyway.
You want to capture an image of a componenet
inside your applet, you do not need to 'capture
the screen' in general.

[ And I would get a bit antsy if you tried
to grab my pornographic desktop image.  ;-) ]

> ..but it would probably not be allowed
> by the security manager for an applet as told to me by a guru.

You may need to sign it either way.

Signature

Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology

Qu?bec - 27 Mar 2004 13:47 GMT
For the sake of the newbees.
I have tried to draw multiple images on an  offScreenGraphics. And then
tried to rotate it with a relative  success.
The rotate filter uses a PixelGrabber.
Qu?bec - 29 Mar 2004 22:59 GMT
Correction with total success.

   Image myOffImage = createImage(72, 72);
   Graphics secondG = myOffImage.getGraphics();
   secondG.drawImage(img[0], 35, 0, null);
   secondG.drawImage(img[1], 15, 0, null);
   secondG.drawImage(img[2], 40, 20, null);
   secondG.drawImage(img[3], 0, 20, null);
   secondG.drawImage(img[4], 20, 40, null);
   secondG.setColor(Color.green);
   secondG.drawString("biz.z..z...z....z", 0, 65);

   //if(imageUpdate(myOffImage, ALLBITS,0, 0, 72,72))
////////////////////////////////////////////////////////////////
   tracker.addImage(myOffImage, 6);
   while (!tracker.checkID(5, true)) {
     pause(50);
   }
///////////////////////////////////////////////////////////////
   g.drawImage(flipV(myOffImage), 5, 5, null);
   g.drawImage(myOffImage, 264, 190, null);
   secondG.dispose();
> For the sake of the newbees.
> I have tried to draw multiple images on an  offScreenGraphics. And then
> tried to rotate it with a relative  success.
> The rotate filter uses a PixelGrabber.
Qu?bec - 29 Mar 2004 23:03 GMT
I must say I how this to Mike Lundy
Andrew Thompson - 29 Mar 2004 23:07 GMT
On Mon, 29 Mar 2004 16:59:22 -0500, Québec wrote:

> Correction with total success.

I still do not understand what you are
trying to do, even now rereading the posts.  

But, ..glad you sorted it!   :-)

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Qu?bec - 30 Mar 2004 03:46 GMT
I am puzzeling a new images from parts of of another image. They are all
painted to an offscreen. Then the offscreen image is flipped and g.drawImage
on the visible area of the applet applet.

To be sure the offscreen image is complete before painting it. I am using a
while loop  to wait for the media tracker to finish the loading.

                   well, I guess you wont understand this either. ;_)

May the illumination be within us.

Jean
Qu?bec - 31 Mar 2004 20:22 GMT
This works in IEXplorer with Microsoft JVM and may not work with
appletviewer 1.1.8
> Correction with total success.
>
[quoted text clipped - 22 lines]
> > tried to rotate it with a relative  success.
> > The rotate filter uses a PixelGrabber.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.