forked from CasterWx/AntzGameOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
354 additions
and
86 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <malloc.h> | ||
|
||
typedef unsigned long DWORD; | ||
typedef int BOOL; | ||
typedef unsigned char BYTE; | ||
typedef unsigned short WORD; | ||
|
||
typedef struct tagBITMAPINFOHEADER{ | ||
DWORD biSize; | ||
long biWidth; | ||
long biHeight; | ||
WORD biPlanes; | ||
WORD biBitCount; | ||
DWORD biCompression; | ||
DWORD biSizeImage; | ||
long biXPelsPerMeter; | ||
long biYPelsPerMeter; | ||
DWORD biClrUsed; | ||
DWORD biClrImportant; | ||
} BITMAPINFOHEADER; | ||
|
||
int ReadBmp(const char* szFileName); | ||
int GetDIBColor(int X, int Y, BYTE *r, BYTE *g, BYTE *b); | ||
|
||
BITMAPINFOHEADER bih; | ||
|
||
BYTE *Buffer = NULL; | ||
|
||
long LineByteWidth; | ||
int main(void) | ||
{ | ||
int x, y; | ||
BYTE r, g, b; | ||
int n; | ||
char szfilename[255] = "122.bmp"; | ||
if (ReadBmp(szfilename) == 0) | ||
{ | ||
printf("failure to read file %s", szfilename); | ||
return 1; | ||
} | ||
printf("Width: %ld\n", bih.biWidth); | ||
printf("Height: %ld\n", bih.biHeight); | ||
printf("BitCount: %d\n\n", (int)bih.biBitCount); | ||
for(int i=0;i<bih.biWidth;i++){ | ||
for(int j=0;j<bih.biHeight;j++){ | ||
if (GetDIBColor(i, j, &r, &g, &b) == 1){ | ||
int rgb = (((int)r/43)+(((int)g/43)*6)+(((int)b/43)*36) + 16); | ||
printf("%d,", rgb); | ||
} | ||
else{ | ||
printf("input error.\n"); | ||
} | ||
} | ||
printf("\n"); | ||
} | ||
|
||
free(Buffer); | ||
return 0; | ||
} | ||
|
||
int ReadBmp(const char* szFileName) | ||
{ | ||
FILE *file; | ||
WORD bfh[7]; | ||
long dpixeladd; | ||
if (NULL == (file = fopen(szFileName, "rb"))) | ||
{ | ||
return 0; | ||
} | ||
printf("%s\n", szFileName); | ||
fread(&bfh, sizeof(WORD), 7, file); | ||
if (bfh[0] != (WORD)(((WORD)'B')|('M'<<8))) | ||
{ | ||
fclose(file); | ||
return 0; | ||
} | ||
fread(&bih, sizeof(BITMAPINFOHEADER), 1, file); | ||
if (bih.biBitCount < 24) | ||
{ | ||
fclose(file); | ||
return 0; | ||
} | ||
dpixeladd = bih.biBitCount / 8; | ||
LineByteWidth = bih.biWidth * (dpixeladd); | ||
if ((LineByteWidth % 4) != 0) | ||
LineByteWidth += 4 - (LineByteWidth % 4); | ||
if ((Buffer = (BYTE*)malloc(sizeof(BYTE)* LineByteWidth * bih.biHeight)) != NULL) | ||
{ | ||
fread(Buffer, LineByteWidth * bih.biHeight, 1, file); | ||
fclose(file); | ||
return 1; | ||
} | ||
fclose(file); | ||
return 0; | ||
} | ||
|
||
int GetDIBColor(int X, int Y, BYTE *r, BYTE *g, BYTE *b) | ||
{ | ||
int dpixeladd; | ||
BYTE *ptr; | ||
if (X < 0 || X >= bih.biWidth || Y < 0 || Y >= bih.biHeight) | ||
{ | ||
return 0; | ||
} | ||
dpixeladd = bih.biBitCount / 8; | ||
ptr = Buffer + X * dpixeladd + (bih.biHeight - 1 - Y) * LineByteWidth; | ||
*b = *ptr; | ||
*g = *(ptr + 1); | ||
*r = *(ptr + 2); | ||
return 1; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<html> | ||
<body> | ||
<pre> | ||
<h1>Build Log</h1> | ||
<h3> | ||
--------------------Configuration: img - Win32 Debug-------------------- | ||
</h3> | ||
<h3>Command Lines</h3> | ||
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F1.tmp" with contents | ||
[ | ||
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/img.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c | ||
"C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp" | ||
] | ||
Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F1.tmp" | ||
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F2.tmp" with contents | ||
[ | ||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/img.pdb" /debug /machine:I386 /out:"Debug/img.exe" /pdbtype:sept | ||
.\Debug\img.obj | ||
] | ||
Creating command line "link.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F2.tmp" | ||
<h3>Output Window</h3> | ||
Compiling... | ||
img.cpp | ||
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(34) : warning C4101: 'x' : unreferenced local variable | ||
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(34) : warning C4101: 'y' : unreferenced local variable | ||
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(36) : warning C4101: 'n' : unreferenced local variable | ||
Linking... | ||
|
||
|
||
|
||
<h3>Results</h3> | ||
img.exe - 0 error(s), 3 warning(s) | ||
</pre> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.