Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (702)
Games in Android Showcase (203)
games submitted by our members
Games in WIP (774)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / J2ME / Creating a transparent image with MIDP 1.0 on: 2003-07-03 04:54:38
Does anyone know how to create a transparent image with MIDP 1.0?

I have a problem when creating the sprites for my game. I will try to explain it.

I have a transparent PNG file with all my tiles and sprites. What I want to do is to create subimages of this file in order to have independent images for each sprite or tile.

MIDP 2.0 API has a method to perform this operation, but MIDP 1.0 hasn't it, and I need to use MIDP 1.0.

So I have created this method on my own:

public Image createImage(Image source, int x, int y, int width, int height)

And the code inside the method is as follows:

Image subimage = Image.createImage(width, height);
Graphics g = subimage.getGraphics();
g.drawImage(source, -x, -y, 0);
return subimage;

It works fine if we don't use transparent images... But when I want to create a transparent subimage it doesn't work, because the method "Image.createImage" creates an image with a white background (and this means that the transparencies are transformed to white).

How can I create a transparent image?  Huh

Is it possible?

If not, I think the solution is to use an "empty" transparent PNG file... (and create all tiles and sprites with the same size, the size of the transparent PNG image)

Thanks for your help.
Pages: [1]
Lunch (43 views)
2016-12-06 16:01:40

ral0r2 (270 views)
2016-11-23 16:08:26

ClaasJG (403 views)
2016-11-10 17:36:32

CoffeeChemist (499 views)
2016-11-05 00:46:53

jay4842 (545 views)
2016-11-01 19:04:52

theagentd (570 views)
2016-10-24 17:51:53

theagentd (552 views)
2016-10-24 17:50:08

theagentd (503 views)
2016-10-24 17:43:15

CommanderKeith (498 views)
2016-10-22 15:22:05

Roquen (460 views)
2016-10-22 01:57:43
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!