Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Using DevIL to make a heightmap from a bmp/jpg file  (Read 3990 times)
0 Members and 1 Guest are viewing this topic.
Offline preshel

Senior Newbie





« Posted 2007-02-11 19:14:46 »

If i load a grayscale image with DevIL, how can i use the data to make a heightmap? what are the access functions for the pixel colors ? I could not find any.

Offline g666

Junior Duke





« Reply #1 - Posted 2007-02-12 12:02:05 »

lwjgl wiki entry:

http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/devil/loadingtextures

desperately seeking sanity
Offline preshel

Senior Newbie





« Reply #2 - Posted 2007-02-12 18:26:58 »

Sorry to say, but im way too newbie to understand what to do with all that code, in order to do what i wanted (in the subject line).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline g666

Junior Duke





« Reply #3 - Posted 2007-02-13 11:08:44 »

for the easist way I would suggest using imageio to load the heightmap texture, then just use getRGB to get the value of a pixel at an (x,y) location: the value is an int where the highest byte is the alpha value, the second highest is red, then green, blue... but you only need one channel, since they are all the same if it is grayscale.

something like:

int height = bufferedImage.getRGB(x, y)&0xff;

desperately seeking sanity
Offline preshel

Senior Newbie





« Reply #4 - Posted 2007-02-13 20:02:47 »

Im a newbie... what is an "imageio" and how to use it to load bmp/jpg images?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2007-02-13 20:28:57 »

So you basicly want us to write everything, put it in a method that you can call?


Quote
Im a newbie... what is an "imageio" and how to use it to load bmp/jpg images?

google Roll Eyes

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline preshel

Senior Newbie





« Reply #6 - Posted 2007-02-14 09:49:36 »

No.

First,
I dont even know in which library it is, and where is the documentation.

Second,
Why using some library, when DevIL exists?
I just dont understand how to implement DevIL for my needs.
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2007-02-14 11:02:01 »

If you actually followed that Google link and read what you found there you'd find the answers you seek. In the meantime I think you might want to research your questions first and avoid pestering people when you obviously need to do some research of your own first.

Cas Smiley

Offline preshel

Senior Newbie





« Reply #8 - Posted 2007-02-14 15:37:12 »

Usually when i'm reading something about a new library, I dont fully understands.

Also, the DevIL documentation practictly dont exists. Just have the methods, and not how to use them.

I looked up for the "imageio" , and i found it, but i could not figure out what to do with it... "image stream" etc. dont mean nothing to me.

maybe i have a deeper problem. How do u guys understand such concepts?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2007-02-14 20:54:18 »

You're trying to write a poem in Chinese... buy a Chinese studybook first, spend a few months studying it.

After you know how to do the basics, you either know what to do all by yourself, or you can come back here and ask some intelligent questions.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline preshel

Senior Newbie





« Reply #10 - Posted 2007-02-15 09:48:05 »

There is no book in DevIL, i guess.
for example, when i see on the documentation:
ilIsValid(int Type, java.lang.String FileName)
I dont know what is it for, what is "Type" param and which constant values are valid for it, etc.

anyhoo, i've got the following code:
1  
2  
3  
4  
5  
6  
7  
8  
        IntBuffer image = BufferUtil.newIntBuffer(1);
        IL.ilGenImages(image);
        IL.ilBindImage(image.get(0));
        IL.ilLoadImage("Data/heightmap1.bmp");
        IL.ilConvertImage(IL.IL_RGB, IL.IL_BYTE);
        ByteBuffer scratch = IL.ilGetData();
        for (int i=0;i<500;i++)
                 System.out.println(""+i+": "+scratch.get(i));


why do i see negative numbers on the output?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2007-02-15 11:36:12 »

Appearantly you don't realize how bytes are representated in memory.

What about learning Java for a start.

This is what I meant with starting with the basics, otherwise you'll have to ask so many questions, that you wouldn't make any progress anyway.


"Thinking in Java" is worth every cent.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #12 - Posted 2007-02-15 12:31:12 »

http://openil.sourceforge.net/tuts/index.htm
http://openil.sourceforge.net/docs/index.php

Offline preshel

Senior Newbie





« Reply #13 - Posted 2007-02-17 20:25:51 »

Thanks Smiley

anyway, I've figured it out i think. I just keep getting that annoying runtime bug again and again.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (66 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 13:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 13:36:02

List of Learning Resources
by Longor1996
2014-08-16 01:40:00

List of Learning Resources
by SilverTiger
2014-08-05 10:33:27

Resources for WIP games
by CogWheelz
2014-08-01 07:20:17

Resources for WIP games
by CogWheelz
2014-08-01 07:19:50

List of Learning Resources
by SilverTiger
2014-07-31 07:29:50

List of Learning Resources
by SilverTiger
2014-07-31 07:26:06
java-gaming.org 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‑gaming.org
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!