Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added simplistic gui (so far windows only)
- Loading branch information
Showing
13 changed files
with
1,938 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
private/ | ||
bin-win/sdl.dll | ||
bin-win/gui_sdl12.exe | ||
thumbs.db | ||
thumbs.db | ||
/ui.bmp |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,57 @@ | ||
#ifdef SDL2 | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include <FreeImage/FreeImage.h> | ||
#include "loader.h" | ||
|
||
static FIBITMAP *dib=NULL; | ||
static uint16_t w,h; | ||
|
||
bool image_loadpicture(const char* filename) { | ||
FREE_IMAGE_FORMAT fif=FIF_UNKNOWN; | ||
int flag=0; | ||
fif=FreeImage_GetFileType(filename,0); | ||
if(fif==FIF_UNKNOWN) { | ||
fif=FreeImage_GetFIFFromFilename(filename); | ||
} | ||
if((fif!=FIF_UNKNOWN)&&FreeImage_FIFSupportsReading(fif)) { | ||
dib=FreeImage_Load(fif,filename,flag); | ||
if(dib) { | ||
w=FreeImage_GetWidth(dib); | ||
h=FreeImage_GetHeight(dib); | ||
if(w>4000||h>4000) { | ||
FreeImage_Unload(dib); | ||
dib=NULL; | ||
} else { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
uint16_t image_width() { | ||
return w; | ||
} | ||
|
||
uint16_t image_height() { | ||
return h; | ||
} | ||
|
||
void image_convert(uint8_t *p_data) { | ||
uint16_t x,y; | ||
RGBQUAD quad; | ||
for(y=0;y<h;y++) { | ||
for(x=0;x<w;x++) { | ||
FreeImage_GetPixelColor(dib,x,y,&quad); | ||
p_data[y*w+x]=(quad.rgbRed+quad.rgbGreen+quad.rgbBlue)/3; | ||
} | ||
} | ||
} | ||
|
||
void image_free() { | ||
if(dib) FreeImage_Unload(dib); | ||
dib=NULL; | ||
} | ||
|
||
#endif |
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,9 @@ | ||
#ifdef SDL2 | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
bool image_load(const char* filename,int flag); | ||
uint16_t image_width(); | ||
uint16_t image_height(); | ||
void image_convert(uint8_t *p_data); | ||
void image_free(); | ||
#endif |
Oops, something went wrong.