[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum moderator: Daddio, Cichor  
Interface bitmaps? How does that work?
TheCossackDate: Sunday, 25/November/2018, 2:35 PM | Message # 1
Noblemen
Group: Users
Messages: 7
Awards: 0
Reputation: 0
Status: Offline
Welp...had to do it again.

Last month I decided to resume the work on the B2W translation I kept unfinished for long time (circa
2007). All good until I reached the interface part. The friggin' BMP's,
dude.... How does modding work here?

All I know, the bitmaps must be saved in Indexed colour mode so they are 8bit. Yet I have did that,
multiple times and multiple image editing programs, GIMP/PS included.
Once I add them to my GP mod file, colours on the menu, for example,
look broken. Yeah, game works and doesn't crash but original GSC bitmaps
and mine I have edited have this colour preset problem, despite I save
them with same settings GSC had; I compared this, same settings,
different results...

I already messaged EbelAngel two times, on the forums here, as well mailed him, but looks like he isn't much active
around anymore.

The modding on the game is dead, no place else to ask questions. Not even on Reddit, ugh...
 
EbelAngelDate: Thursday, 10/January/2019, 8:26 AM | Message # 2
Site Administrator
Group: Administrators
Messages: 996
Awards: 7
Reputation: 12
Status: Offline
I don't remember how this worked at all, it's been far too long since I looked at Cossacks 1.

Were these .bmp's packed in .gp files? If so it seems like a palette issue, weren't there folders in the gp packer tool , one for Cossacks 1, one for AC and one for interface files? (/0/,/1/,/2/ folders). Perhaps the interface file's one is for AC in the tool.

You know who you could possibly ask, it's the Russians on the Cossacks 3 forums, to be more specific, Awar ( http://www.cossacks3.com/forum/index.php?members/awar.13278/ ) , he used to make a mod for Cossacks 1 and had edited interface files if I remember correctly ( I could also be entirely wrong).

If all fails, you can always try GSC themselves on their forum. Pm Bodun ( http://www.cossacks3.com/forum/index.php?members/bodun.14002/ ) , explain your issue, someone might know or remember how to, although most of the former GSC staff is no longer at GSC.


 
TheCossackDate: Saturday, 12/January/2019, 0:19 AM | Message # 3
Noblemen
Group: Users
Messages: 7
Awards: 0
Reputation: 0
Status: Offline
Sh*t, I've been checking on the forums for 3 months now, holding hopes someone will reply back with a solution.

Let me explain this fair and simple.

Nope, the GP files contain only in-game materials, like icons of objects, buttons. In fact, these interface bitmaps are packed in the ALL.gsc archive and located in the INTERFACE folder (if you don't check the "+" option). From what I could gather they are in 1024x768 resolution and standard 8bit format (Indexed), no compression or mip maps, just common bitmap images used as background images for the menu, you don't need to decompress them as they are readable once you unpack the all.gsc archive.

I'd have thought if its a palette issue but that goes only for the .GP files, not the .BMPs.

I tried whatnot already, went through doing the same thing across 3 image editors, GIMP, PaintNET and older Photoshop version (CS2). All produce the exact same image results, even the file size matches. I had the same size of the original MAIN MENU image, yet in game it looks broken. If I open it using Windows' own picture viewer, no problems.

I can't figure it, I tried to... DAMIT.

I can supply the bitmaps to you if you think you can break it down. Steam copy of Back to War + the Campaign addon here.
 
EbelAngelDate: Wednesday, 16/January/2019, 3:34 PM | Message # 4
Site Administrator
Group: Administrators
Messages: 996
Awards: 7
Reputation: 12
Status: Offline
Meh, i don't know, just had a quick look, I can't even open those .bmp's with todays photoshop or windows viewer?

So had a quick glance at the source. Was there ever a 'bmp tool'? I see this in the engine source:

bmptool.cpp

Code
#include "stdio.h"
#include "windows.h"
//#include "stdafx.h"
#include "ResFile.h"
#include "math.h"
#include "bmptool.h"
void SaveToBMP24(char* Name,int Lx,int Ly,byte* data){
    ResFile f1=RRewrite(Name);
    BMPformat BM;
    BM.bfType='MB';
    int rlx=Lx*3;
    if(rlx&3)rlx=(rlx|3)+1;
    BM.bfSize=(sizeof BMPformat)+rlx*Ly;
    BM.bfReserved1=0;
    BM.bfReserved2=0;
    BM.bfOffBits=(sizeof BMPformat);
    BM.biSize=40;
    BM.biWidth=Lx;
    BM.biHeight=Ly;
    BM.biPlanes=1;
    BM.biBitCount=24;
    BM.biCompression=BI_RGB;
    BM.biSizeImage=0;
    BM.biXPelsPerMeter=0;
    BM.biYPelsPerMeter=0;
    BM.biClrUsed=0;
    BM.biClrImportant=0;
    RBlockWrite(f1,&BM,sizeof BM);
    for(int j=0;j<Ly;j++){
        RBlockWrite(f1,&data[3*Lx*(Ly-j-1)],rlx);
    };
    RClose(f1);
};
bool ReadBMP24(char* Name,BMPformat* BM,byte** data){
    ResFile f1=RReset(Name);
    if(f1!=INVALID_HANDLE_VALUE){
        RBlockRead(f1,BM,sizeof BMPformat);
        if(IOresult()||BM->bfType!='MB')return false;
        if(BM->biBitCount!=24)return false;
        *data=new byte[BM->biWidth*BM->biHeight*3];
        int wid=BM->biWidth*3;
        int rwid=wid;
        if(wid&3)rwid=(wid|3)+1;
        for(int i=0;i<BM->biHeight;i++){
            RSeek(f1,(sizeof BMPformat)+(BM->biHeight-i-1)*rwid);
            RBlockRead(f1,&((*data)[i*wid]),wid);
        };
        RClose(f1);
        return true;
    }else return false;
};
bool ReadBMP8(char* Name,BMPformat* BM,byte** data){
    ResFile f1=RReset(Name);
    if(f1!=INVALID_HANDLE_VALUE){
        RBlockRead(f1,BM,sizeof BMPformat);
        if(IOresult()||BM->bfType!='MB')return false;
        if(BM->biBitCount!=8)return false;
        *data=new byte[BM->biWidth*BM->biHeight];
        int wid=BM->biWidth;
        int rwid=wid;
        if(wid&3)rwid=(wid|3)+1;
        for(int i=0;i<BM->biHeight;i++){
            RSeek(f1,(sizeof BMPformat)+1024+(BM->biHeight-i-1)*rwid);
            RBlockRead(f1,&((*data)[i*wid]),wid);
        };
        RClose(f1);
        return true;
    }else return false;
};
bool ReadBMP8TOBPX(char* Name,byte** data){
    BMPformat BM;
    ResFile f1=RReset(Name);
    if(f1!=INVALID_HANDLE_VALUE){
        RBlockRead(f1,&BM,sizeof BMPformat);
        if(IOresult()||BM.bfType!='MB')return false;
        if(BM.biBitCount!=8)return false;
        *data=new byte[BM.biWidth*BM.biHeight+4];
        int wid=BM.biWidth;
        int rwid=wid;
        if(wid&3)rwid=(wid|3)+1;
        ((short*)*data)[0]=BM.biWidth;
        ((short*)*data)[1]=BM.biHeight;
        for(int i=0;i<BM.biHeight;i++){
            RSeek(f1,/*(sizeof BMPformat)+1024*/BM.bfOffBits+(BM.biHeight-i-1)*rwid);
            RBlockRead(f1,&((*data)[i*wid+4]),wid);
        };
        RClose(f1);
        return true;
    }else return false;
};
bool LoadBitmapLikeGrayscale(char* Name,int* Lx,int* Ly,byte** res){
    byte* data;
    BMPformat BM;
    if(ReadBMP24(Name,&BM,&data)){
        int LX=BM.biWidth;
        int LY=BM.biHeight;
        *res=new byte [LX*LY];
        for(int ix=0;ix<LX;ix++)
            for(int iy=0;iy<LY;iy++){
                int ofs=(ix+iy*LX);
                int ofs3=ofs*3;
                int v=int(data[ofs3]+data[ofs3+1]+data[ofs3+2])/3;
                (*res)[ofs]=v;
            };

        free(data);
        *Lx=BM.biWidth;
        *Ly=BM.biHeight;
        return true;
    };
    return false;
};
int GetResVal(byte* res,int LX,int LY,int RLX,int RLY,int x,int y){
    int vx=(x*LX)/RLX;
    int vy=(y*LY)/RLY;
    int rx=(vx*RLX)/LX;
    int ry=(vy*RLX)/LY;
    int rx1=((vx+1)*RLX)/LX;
    int ry1=((vy+1)*RLY)/LY;
    int vx1=vx+1;
    int vy1=vy+1;
    if(vx<0)vx=0;
    if(vy<0)vy=0;
    if(vx1<0)vx1=0;
    if(vy1<0)vy1=0;
    if(vx>=LX)vx=LX-1;
    if(vy>=LY)vy=LY-1;
    if(vx1>=LX)vx1=LX-1;
    if(vy1>=LY)vy1=LY-1;
    int z1=res[vx+LX*vy];
    int z2=res[vx1+LX*vy];
    int z3=res[vx+LX*vy1];
    int z4=res[vx1+LX*vy1];
    return z1+((x-rx)*(z2-z1))/(rx1-rx)+((y-ry)*(z3-z1))/(ry1-ry)-(((z2+z3-z1-z4)*(x-rx)*(y-ry))/(rx1-rx)/(ry1-ry));
};
byte* DATA;
DWORD GetSumm(char* Name){
    ResFile F=RReset(Name);
    if(F!=INVALID_HANDLE_VALUE){
        int sz=RFileSize(F);
        
        RBlockRead(F,DATA,sz);
        RClose(F);
        DWORD SZZ=0;
        for(int i=0;i<sz;i++)SZZ+=DATA[i];
        SZZ&=65535;
        return SZZ;
    }else return 0;
};
extern HWND hwnd;
void CheckIntegrity(){
    FILE* F=fopen("Data\\crc.dat","r");
    FILE* F1=fopen("Data\\crc1.dat","w");
    DATA=(byte*)malloc(2000000);
    bool ERR=0;
    if(F&&F1){
        char ccc[128];
        DWORD xx;
        int z;
        do{
            z=fscanf(F,"%s%d",ccc,&xx);
            if(z==2){
                DWORD SS=GetSumm(ccc);
                if(!(GetKeyState(VK_CONTROL)&0x8000)){
                    if(xx!=SS&&!ERR){
#ifdef INETTESTVERSION
                        char cc2[256];
                        sprintf(cc2,"File was corrupted or modified by user: %s, may be you have not copied ALL files of patch to this directory. Try to copy ALL files, even from subdirectories!!! Othervice you will have SYNCRONIZATION FAILURE during the network game. If nothing helps then delete this folder with addon, copy T016 version then copy files from last update folder.",ccc);
                        MessageBox(hwnd,cc2,"SYNCRONIZATION WARNING!!!",0);
#else
                        char cc2[256];
                        sprintf(cc2,"File was corrupted or modified by user: %s",ccc);
                        MessageBox(hwnd,cc2,"SYNCRONIZATION WARNING!!!",0);
#endif
                        ERR=1;
                    };
                };
                fprintf(F1,"%s %d\n",ccc,SS);
            };
        }while(z==2);
        fclose(F);
        fclose(F1);
        if(ERR)exit(0);
    };
    free(DATA);
};
#undef free
#undef malloc
int TotalSize=0;
#define CEXPORT __declspec(dllexport)
CEXPORT
void _ExFree(void* ptr){
    DWORD* Ptr=(DWORD*)ptr;
    try{
        if(Ptr&&Ptr[0]!=0xcdcdcdcd){
            free(ptr);
            TotalSize--;
        };
    }catch(...){
    };
};
CEXPORT
void* _ExMalloc(int Size){
    TotalSize++;
    return calloc(Size,1);
};[/i]

bmptool.h

Code
typedef unsigned char byte;
#pragma pack(1)
struct BMPformat{ // bmfh
        WORD    bfType;
        DWORD   bfSize;
        WORD    bfReserved1;
        WORD    bfReserved2;
        DWORD   bfOffBits;
        DWORD   biSize;
        LONG    biWidth;
        LONG    biHeight;
        WORD    biPlanes;
        WORD    biBitCount;
        DWORD   biCompression;
        DWORD   biSizeImage;
        LONG    biXPelsPerMeter;
        LONG    biYPelsPerMeter;
        DWORD   biClrUsed;
        DWORD   biClrImportant;
};
void SaveToBMP24(char* Name,int Lx,int Ly,byte* data);
bool ReadBMP24(char* Name,BMPformat* BM,byte** data);
bool ReadBMP8(char* Name,BMPformat* BM,byte** data);
bool ReadBMP8TOBPX(char* Name,byte** data);


 
TheCossackDate: Thursday, 17/January/2019, 0:31 AM | Message # 5
Noblemen
Group: Users
Messages: 7
Awards: 0
Reputation: 0
Status: Offline
Hmm! Not quite sure either regarding a "BMP Tool" made by the community or even GSC itself? I looked twice around the internet about that before.

In order to decompress the images, I use GSC File Utility 0.11 (downloaded from the download section, so you should have the same version too). Here, I'm uploading 'em for you if you have something in mind to try. These are decompressed using the "+" option, for easier packing back into the .GSC mods file.

https://www.sendspace.com/file/lnrbxk

Like I said, I can open them in any image viewer and editor - saving breaks them in an awkward way. The other day I even did process the MAIN MENU one again on my WindowsXP laptop using GIMP - not a slight change. One could think Windows 7 may cause the issue but unlikely. I ran out of ideas.


Message edited by TheCossack - Thursday, 17/January/2019, 0:32 AM
 
寒青Date: Thursday, 19/September/2019, 10:16 AM | Message # 6
Noblemen
Group: Users
Messages: 5
Awards: 0
Reputation: 0
Status: Offline
You should save the palette of the original bitmaps by PS . Then when you made a new picture ,you should cover it to Index mode with the palette whitch you saved.
 
  • Page 1 of 1
  • 1
Search: