Welcome to Dream.In.Code
Become a Java Expert!

Join 150,129 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,098 people online right now. Registration is fast and FREE... Join Now!




how would i make an image transparent?

 
Reply to this topicStart new topic

how would i make an image transparent?

zach123b
16 Jun, 2008 - 02:01 PM
Post #1

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 6

this isnt h/w for im out of school
im trying to make a game like fire emblem. how would i make an image transparent where it doesnt draw the white around the image? if u want i could add my code but i dont think it would help much >>
User is offlineProfile CardPM
+Quote Post

pbl
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 02:46 PM
Post #2

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(zach123b @ 16 Jun, 2008 - 03:01 PM) *

this isnt h/w for im out of school
im trying to make a game like fire emblem. how would i make an image transparent where it doesnt draw the white around the image? if u want i could add my code but i dont think it would help much >>

Or you draw your image pixel by pixel or it is in the .gif file property that some pixels must be transparent
User is offlineProfile CardPM
+Quote Post

zach123b
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 03:12 PM
Post #3

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 6

hmmmm how would i draw it pixel by pixel? for im using .jpg
could use .gif instead tho..
User is offlineProfile CardPM
+Quote Post

pbl
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 03:22 PM
Post #4

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(zach123b @ 16 Jun, 2008 - 04:12 PM) *

hmmmm how would i draw it pixel by pixel? for im using .jpg
could use .gif instead tho..

BufferedImage has 2 getRGB() methods
If the RGB is the one of the background of your image, just don't paint it

This post has been edited by pbl: 16 Jun, 2008 - 03:23 PM
User is offlineProfile CardPM
+Quote Post

zach123b
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 03:53 PM
Post #5

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 6

sweet just how do i paint 1 pixel from an image?
User is offlineProfile CardPM
+Quote Post

pbl
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 04:02 PM
Post #6

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(zach123b @ 16 Jun, 2008 - 04:53 PM) *

sweet just how do i paint 1 pixel from an image?

You are rigth Graphics does not have a drawPixel() method
I guess you can drawRectangle width width = 1 and height = 1
but the real way to proceed is to use a .gi or .jpg with transparent pixels
User is offlineProfile CardPM
+Quote Post

zach123b
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 04:05 PM
Post #7

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 6

alright how do i use transparent pixels? for im drawing an image (character's image) on top of the ground (grass or stones)?
User is offlineProfile CardPM
+Quote Post

pbl
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 04:23 PM
Post #8

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(zach123b @ 16 Jun, 2008 - 05:05 PM) *

alright how do i use transparent pixels? for im drawing an image (character's image) on top of the ground (grass or stones)?

I know how to draw one (.gif, .jpg, .bmp) not using Ms-Paint but other programs let you do so.
This out of the context of this forum
Suggest you Google for it

This post has been edited by pbl: 16 Jun, 2008 - 06:16 PM
User is offlineProfile CardPM
+Quote Post

zach123b
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 05:33 PM
Post #9

New D.I.C Head
*

Joined: 4 Apr, 2008
Posts: 6

alright, well thnx for ur help tongue.gif
User is offlineProfile CardPM
+Quote Post

1lacca
RE: How Would I Make An Image Transparent?
16 Jun, 2008 - 11:31 PM
Post #10

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
jpg would be cumbersome to use, because it usually uses a lossy algorithm, and your background/transparent color would mutate into another color. GIF and PNG support transparency out of the box.

Transparency and pixel drawing is possible via the BufferedImage class. There you have methods getAlphaRaster and getRaster. They'll return WritableRaster objects that have setRGB method to set individual pixels.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:43AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month