Author Topic: YES!!! BMP to typ File Convertor  (Read 525 times)

Offline F1Bomber

  • Copper Member
  • **
  • Posts: 214
      • http://www.bushtech.com.au
YES!!! BMP to typ File Convertor
« on: October 25, 2003, 03:03:26 AM »
Okay i had to make a program to convert a bmp image to a typ file for the aces high terrian engine.

Its simply accepts a bmp image, and you add in the color types that you have put into the 24 bit 512 pixcel., 512 pixcel image. And it spits out the terrian as a typ file. Put the typ file into your terrian and wala, your got your WHOLE terrian textured without needing to use ah editor.

Still working on it, but will have a demo pretty soon.

Offline NHawk

  • Silver Member
  • ****
  • Posts: 1787
YES!!! BMP to typ File Convertor
« Reply #1 on: October 25, 2003, 03:36:45 PM »
And what's the difference between this and AK's BMP2MAP?
Most of the people you meet in life are like slinkies. Pretty much useless, but still bring a smile to your face when you push them down the stairs.
-------------------------------
Sometimes I think I have alzheimers. But then I forget about it and it's not a problem anymore.

Offline Shiva

  • Silver Member
  • ****
  • Posts: 966
      • http://members.cox.net/srmalloy/
YES!!! BMP to typ File Convertor
« Reply #2 on: October 26, 2003, 01:49:50 AM »
Quote
Originally posted by NHawk
And what's the difference between this and AK's BMP2MAP?


If you don't want to accept BMP2MAP's height-to-terrain-type conversion algorithm, you can roll your own with this.

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
YES!!! BMP to typ File Convertor
« Reply #3 on: October 26, 2003, 01:04:36 AM »
Do you have exectly description of all this formats: typ, elv etc.. and the rest......

I'd like to write some usefull utilites for file convertion, clipboard map building, filling it with objects. Sometimes it is more usefull to work with numbers and not trying to put object of fields exectly.

thank you
Artik, 101 "Red" Squadron, Israel

Offline F1Bomber

  • Copper Member
  • **
  • Posts: 214
      • http://www.bushtech.com.au
YES!!! BMP to typ File Convertor
« Reply #4 on: October 26, 2003, 04:25:11 AM »
OKay i have attached the following files and the address were to get them from.

You will need java run time enviroment to actualy use this program. I wont be holding anyones hands and walking them though the proccess but here is the requirements for the little program.

BMP Image , 512 X 512 pixcel. 24 Bit color.
Place the bmp image that you wish to be converted onto c:\ drive.
run the following program with the following in command promot

java Changer

This will make a file called Demo.typ

Copy and past this into your folder that currently holds your map for example, i have a folder called demo, i place the demo.typ file into that folder.

Run ahedit and see your new terrian.
---------------------------------------------------------------------------

Okay heres a walkthough for people who dont really understand the above.

1. Open paint
2. Copy and past this file into paint.


3. You will see pre-defined color pattern on the top right hand side of this image above. These are the following order.

Black - water
Green - grass
Dark Green - Forest
Brown - Farm
White - snow
Grey - Rocky

Next you will see the little island that i have created using those above color patters.

P.S Please dont use photshop or paintsho pro, the program is very basic and will only read the colors above.  Or you can use them, but just use hard tools that dont creat white pixcels of different color types when you mix them.

4. Rember your map needs to be 512 pixcel by 512 pixcel, ahedit will die if your bmp map isnt 512 x 512.

5. Run the java application

6. Copy and past into the aheditor and see the difference.
Hes is a image i have included.


add some height into the terrian and you got this.

Offline F1Bomber

  • Copper Member
  • **
  • Posts: 214
      • http://www.bushtech.com.au
YES!!! BMP to typ File Convertor
« Reply #5 on: October 26, 2003, 04:33:31 AM »
Here is the java file
http://www.bushtech.com.au/chads/demo/Changer.class

Source code..
 *
 * Created on October 25, 2003, 12:53 PM
 */

/**
 *
 * @author  Chad Lion
 */
import java.io.*;
public class Changer {
   
    /** Creates a new instance of Changer */
    public Changer() {
        try{
            // Open File and start a fiel called demo.typ
        File inputFile = new File("c:\\demo.bmp");
        File outputFile = new File("c:\\demo.typ");

        FileReader in = new FileReader(inputFile);
        FileWriter out = new FileWriter(outputFile);
        int c;
        int b;
        int e;

        while ((c = in.read()) != -1){
                b = in.read();
                e = in.read();            
                         
                // Grass
                if( (c == 8364 )&&(b == 255) && (e == 0) ){
                out.write( 1 );
                }
               
                // farm
                if( (c == 0 )&&(b == 8364) && (e == 8364) ){
                out.write( 3 );
                }
               
                // Forest
                if( (c == 0 )&&(b == 8364) && (e == 0) ){
                out.write( 5 );
                }
               
                // Rocky
                if( (c == 8364 )&&(b == 8364) && (e == 8364) ){
                out.write( 2 );
                }
               
                // Snow
                if( (c == 255 )&&(b == 255) && (e == 255) ){
                out.write( 6 );
                }
               
               
                if( (c == 0 )&&(b == 0) && (e == 0) ){
                out.write( 0 );
                }

        }
        in.close();
        out.close();
        System.out.println( "finish" );
        }
        catch( Exception e ){};
    }


    public static void main( String args[] ){
        Changer hse = new Changer();
    }

}

// You accept the code as is.
// P.S if your going to edit the code for future use do the following.
BMP format 28,80,60
SWAP left and right
                   60,80,28
Will give you the correct value to edit.

Very basic, because i only want to use it once, and then kill it.

Offline F1Bomber

  • Copper Member
  • **
  • Posts: 214
      • http://www.bushtech.com.au
YES!!! BMP to typ File Convertor
« Reply #6 on: October 26, 2003, 05:21:42 AM »
Okay basic rundown of the typ file type.

Each mile has a value of either 1,2,3,4,5,6,0 interger value type. The typ file basicaly holds these values for the 512,512 square map. Though i only noticed this well reading the value within the typ file and testing out different example.

So if you want to creat your own program all you have to do is follow this.

Read RGB Pixcel color. Depend on the type the color is, then either write a 0 to 6 into a typ file depending on what tile you want.


You will see from my program above, that i read in 3 values. The 3 Values are the different colors for the RGB bitmap. THen depending on the RGB color i write a 0 to 6 depending on the input. Its as easy as that. It does the job, and i hope you can find this information helpfull for building your own program to do this. But i dont have the time to mess around with the file types right now.

Offline Dux

  • Aces High CM Staff (Retired)
  • Platinum Member
  • ******
  • Posts: 7333
YES!!! BMP to typ File Convertor
« Reply #7 on: October 27, 2003, 10:08:47 AM »
Just FYI... you can open a .typ file in Photoshop also.
Rogue Squadron, CO
5th AF, FSO Squadron, Member

We all have a blind date with Destiny... and it looks like she's ordered the lobster.

Offline zmeg

  • Silver Member
  • ****
  • Posts: 936
YES!!! BMP to typ File Convertor
« Reply #8 on: October 27, 2003, 11:36:56 AM »
How do you open a typ file in photoshop, are we talking about the same kind of typ file?

Offline BenDover

  • Platinum Member
  • ******
  • Posts: 5803
YES!!! BMP to typ File Convertor
« Reply #9 on: October 27, 2003, 02:31:25 PM »
Are you on about the RAW way dux?

Offline Dux

  • Aces High CM Staff (Retired)
  • Platinum Member
  • ******
  • Posts: 7333
YES!!! BMP to typ File Convertor
« Reply #10 on: October 27, 2003, 02:56:42 PM »
Yes, use the RAW option. It pretty much guesses the right size, etc.

Here's the trick, though... when it opens it'll look like a pure black square; it isn't. Change it to Indexed Color mode and open the Color Table. Change the first 6 colors in the palette to something more meaningful... color 1 = blue (water), color 2 = green (grass), etc.

Paint the terrain (using those 6 colors) the way you want it, and close out of the file... no "save as..." or anything. Just Quit and Save.

Works like a charm. :)
Rogue Squadron, CO
5th AF, FSO Squadron, Member

We all have a blind date with Destiny... and it looks like she's ordered the lobster.