Page 1 of 1

Battle Mages DISPLACE.BIN

Posted: Tue Mar 28, 2017 2:10 pm
by ermaccer
The most i could decode of it:
Image

Seems to be some float array.

Re: Battle Mages DISPLACE.BIN

Posted: Wed Apr 05, 2017 1:22 am
by herbert3000
Hi, the file is not a usual image file. It's an array of 128 x 128 floating point numbers (IEEE 754).

I see 3 possibilites here for converting the .bin files into a format that you can work with.

1) Convert it to an 8-bit grayscale bitmap. Pros: you can edit it with many programs, cons: you would lose precision.
The minimum value in displace.bin is 193.0 the maximum is 759.0, for a grayscale bitmap, the values need to streteched so they fit into a [0,255] interval. This leads to a loss in precision.

2) Convert it to a 16-bit grayscale bitmap. Pros: No precision loss, cons: you need a program that can handle 16-bit images.

3) Convert it to an .OBJ file. Pros: No precision loss, cons: you need a 3D program to edit the file.

Here's the file converted to a 8-bit grayscale bmp:
displace_193_759.bmp

Re: Battle Mages DISPLACE.BIN

Posted: Wed Apr 05, 2017 9:48 pm
by ermaccer
Thanks.
How did you generate it?

Re: Battle Mages DISPLACE.BIN

Posted: Thu Apr 06, 2017 12:25 am
by herbert3000
I used MATLAB to convert the binary file into an image.
Don't know if that's the best method, but here's the code I used:

Code: Select all

% open file
file = fopen('displace.bin');

% read content of file into a 128x128 float matrix
A = fread(file, [128,128], 'float');

% transpose matrix
A = A';

% close file
fclose(file);

% get minimum and maximum value
amin = min(min(A));
amax = max(max(A));

% convert matrix to grayscale image
I = mat2gray(A, [amin amax]);

% convert image to 16-bit, without the conversion the output image would only be 8-bit
I =  uint16(I * 65535);

% show image in Matlab
imshow(I);

% write image to file
imwrite(I, 'displace.png');