drawing image??

i create a map editor.
and now i’m in progress in making selection tools
but i stuck in drawing the selected image different from the others? >:( example i pick a fence object, and i want the fence object drawn red or transparent.
is anyone know how to draw image in one color?
or make the image transparent? or whatever to change the image into something different from the other

thanxx

have some links:
http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=2D;action=display;num=1042426804
http://www.josrts.org/cgi-bin/ikonboard/ikonboard.cgi?s=3a577701605d528cec40323a938dffad;act=ST;f=1;t=138;st=0;&#entry1567

[quote]anyone know how to draw image in one color?
or make the image transparent? or whatever to change the image into something different from the other
[/quote]
The easiest way to do this for something static like a map editor where your images can be prerender is to use the pixelGrabber class. After you have all of your pixels in an int array simply pass them through a color parser that modifies the pixels that aren’t transparent to one set color (red). Then call use the memoryImageSource class to create an image out of it. This image won’t be accelerated but if you then copy that image onto a offscreen image through createCompatibleImage(…) you can gain hardware acceleration.

You can find many examples by doing a search for PixelGrabber. They will show you how to do the shifting to set each of the Red,Green,Blue and Alpha’s of your pixel. I also have some code I could dig up if you can’t find anything useful and you decide to use this technique.

There are better (memory wise) ways to create this effect, but this is probably the easiest and a map editor shouldn’t be too memory intensive.

yup. i get the point. :smiley:
but it’ll take to much overhead since i have many images :’(
my map editor use big memory and slow in performance, cos it open more than one map each time(each map dimension is about 2000x2000), i use JInternalFrame for that.
if i use pixelgrabber, i’m afraid the editor will be very very slow. :-[
any faster idea :wink:

have you had a look at java.awt.image.ColorConvertOp
(and all the other RasterOp classes for that matter)

Look into compositing modes of java2D

You can likely blend the image with a colour simply by changing the compositing mode and the alpha value, so that you can ‘tint’ the object a certain color and then draw it to the screen.

I think that would be the simplest way, and likely the fastest.

okay guys… i have solved this problem
thanxx
i use composite like swpalmer said.
the fence now look transparent ;D

thank you