Page 2 of 2
PostPosted: 08 Oct 2009, 07:21
by Krom
Why not

You can load a height map from Google search and use it. Also it could be used to make image-maps, you know, color section into green-yellow-brown-blue to make a sort of picture as well with height

PostPosted: 08 Oct 2009, 07:41
by Thunderwolf
Never used the load image thing... and by the looks of it, probably never will.
PostPosted: 08 Oct 2009, 21:53
by Ben
Yeah I'm not saying that it isn't usful, but just that I don't think I will ever be in situation where it will be effective.
PostPosted: 08 Dec 2009, 21:18
by Thunderwolf
Hey,
sorry for necroposting in this topic, but can anyone tell me what I'm doing wrong here?
Height directly into color (0-100)
Height*2.55 (0-255 (8bit) radius)
P.S. I'm using m1 (TSK version)
PostPosted: 09 Dec 2009, 06:29
by Krom
You are doing everything right, but whats the problem?
PostPosted: 09 Dec 2009, 08:43
by Thunderwolf
The problem is that when I use that load image thingy, it doesn't look like the original (well, it almost looks like the original, but not completely).
Loaded your map editor twice with tsk m1 loaded, then loaded the heightmap in one of them, it looked 'different'...
b.t.w. Does your editor also do something with DirectX? when the overwritten ddraw.dll is in the knights and merchants folder, the map editor doesn't show up... when renaming or removing the file again it works...
PostPosted: 09 Dec 2009, 12:54
by Krom
Maybe the way you've got the "original" image changed it somehow? I don't remember my code by line, but it's pretty straightforward - replace maps height with data from image. Anyway the thing is to let you create relief in Photoshop and then import it, nothing more. Although it's interesting what else could be done with this function

PostPosted: 09 Dec 2009, 13:23
by Thunderwolf
I'll try playing around with it for a bit more...
This is my current (C#) code:
- Code:
Bitmap bmp = new Bitmap(width, height);
for (int i = 0; i < width; i++)
{
  for (int j = 0; j < height; j++)
  {
    //put block data at coords into blockData
    offset = (width * i) + j;
    for (int k = 8 + (offset * 23); k < 23 + 8 + (offset * 23); k++)
    {
      blockData[k - (8 + (23 * offset))] = allBytes[k];
    }
    int heightInBMP = blockData[2];
    Color c = new Color();
    heightInBMP = Convert.ToInt32(Convert.ToDouble(heightInBMP) * 2.55);
    c = Color.FromArgb(heightInBMP, heightInBMP, heightInBMP);
    bmp.SetPixel(j, i, c);
  }
}
bmp.Save("heightmap.bmp", System.Drawing.Imaging.ImageFormat.Bmp);[/quote]
PostPosted: 09 Dec 2009, 13:31
by harold
- Code:
Convert.ToInt32(Convert.ToDouble(heightInBMP) * 2.55); [/quote]
Why???
You don't need doubles, and you certainly don't need to use Convert (which is evil!)
[code](heightInBMP * 255)/100[/quote]
PostPosted: 09 Dec 2009, 13:33
by Krom
Also keep in mind that all values ahould be unsigned.. probably you already did, but just in case
PostPosted: 09 Dec 2009, 13:56
by Thunderwolf
- Code:
Convert.ToInt32(Convert.ToDouble(heightInBMP) * 2.55); [/quote]
Why???
You don't need doubles, and you certainly don't need to use Convert (which is evil!)
[code](heightInBMP * 255)/100[/quote][/quote]
yeah.. uh.. I did write that code quickly.. updated it now though, it does generate the same image...
[code]Also keep in mind that all values ahould be unsigned.. probably you already did, but just in case[/quote]
bitmap.setpixel doesn't accept uint (?)... all values are positive though.