Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify bitmap and bitmapmask #20

Merged
merged 4 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions include/ace/utils/bitmapmask.h

This file was deleted.

119 changes: 0 additions & 119 deletions src/ace/utils/bitmapmask.c

This file was deleted.

64 changes: 45 additions & 19 deletions tools/bitmap_conv/bitmap_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,40 @@ void writeMask(
uint8_t *pImgData,
uint16_t uwWidth, uint16_t uwHeight
) {
uint16_t x,y, uwPixelBuffer;
uint8_t i, ubPlaneCount;
uint16_t x, y, uwPixelBuffer;
uint32_t ulPos;
FILE *pOut;
pOut = fopen(g_szMaskOutputPath, "wb");

if(uwWidth & 0xF) {
printf("Width is not divisible by 16!\n");
return;
}

pOut = fopen(g_szMaskOutputPath, "wb");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, fixed!

if(!pOut) {
printf("Can't write to file %s\n", g_szMaskOutputPath);
return;
}
// Write mask header

ubPlaneCount = 1;

// Write .bm header
writeByte(uwWidth >> 8, pOut);
writeByte(uwWidth & 0xFF, pOut);
writeByte(uwHeight >> 8, pOut);
writeByte(uwHeight & 0xFF, pOut);
writeByte(ubPlaneCount, pOut);
writeByte(0, pOut); // Version
writeByte(0, pOut); // Flags
for(i = 0; i != 2; ++i)
writeByte(0, pOut);

// Write mask data
for(y = 0; y != uwHeight; ++y) {
uwPixelBuffer = 0;
for(x = 0; x != uwWidth; ++x) {
// Determine color
ulPos = y*uwWidth*3 + x*3;

uwPixelBuffer <<= 1;
Expand All @@ -235,33 +251,44 @@ void writeMask(
}
}
}

fclose(pOut);
}

void writeMaskInterleaved(
uint8_t *pImgData,
uint16_t uwWidth, uint16_t uwHeight, uint16_t uwPaletteCount
) {
uint16_t x,y, uwPixelBuffer;
uint8_t i, ubBpp, ubPlane;
uint16_t x, y, uwPixelBuffer;
uint32_t ulPos;
uint8_t ubPlane, ubBpp, i;
FILE *pOut;

ubBpp = 1;
for(i = 2; i < uwPaletteCount; i <<= 1)
++ubBpp;

pOut = fopen(g_szMaskOutputPath, "wb");

if(uwWidth & 0xF) {
printf("Width is not divisible by 16!\n");
return;
}

pOut = fopen(g_szMaskOutputPath, "wb");
if(!pOut) {
printf("Can't write to file %s\n", g_szMaskOutputPath);
return;
}
// Write mask header

ubBpp = 1;
for(i = 2; i < uwPaletteCount; i <<= 1)
++ubBpp;

// Write .bm header
writeByte(uwWidth >> 8, pOut);
writeByte(uwWidth & 0xFF, pOut);
writeByte((uwHeight*ubBpp) >> 8, pOut);
writeByte((uwHeight*ubBpp) & 0xFF, pOut);
writeByte(uwHeight >> 8, pOut);
writeByte(uwHeight & 0xFF, pOut);
writeByte(ubBpp, pOut);
writeByte(0, pOut); // Version
writeByte(1, pOut); // Flags
for(i = 0; i != 2; ++i)
writeByte(0, pOut);

// Write mask data
for(y = 0; y != uwHeight; ++y) {
Expand All @@ -280,8 +307,8 @@ void writeMaskInterleaved(
}
}
}
fclose(pOut);

fclose(pOut);
}

uint8_t paletteLoad(char *szPath, tColor *pPalette) {
Expand Down Expand Up @@ -423,7 +450,7 @@ int determineArgs(int argc, char *argv[]) {
if(!strlen(g_szMaskOutputPath) && g_uwMaskR != 0xFFFF) {
memcpy(g_szMaskOutputPath, g_szInputPath, uwPathLen);
g_szMaskOutputPath[uwPathLen] = '\0';
strcat(g_szMaskOutputPath, ".msk");
strcat(g_szMaskOutputPath, "_mask.bm");
}

return 1;
Expand Down Expand Up @@ -531,7 +558,6 @@ void writePlanes(FILE *pOut, uint8_t *pData, uint16_t uwWidth, uint16_t uwHeight
}
*/


/**
* This implementation is painfully slow, but it eats as little memory as possible
*/
Expand Down
Binary file modified tools/bitmap_conv/bitmap_conv.exe
Binary file not shown.