mirror of https://github.com/nothings/stb-imv
version 0.93 changes
This commit is contained in:
parent
609a90d6e0
commit
9e0f63ad87
84
imv.c
84
imv.c
|
@ -540,7 +540,7 @@ int upsample_cubic = TRUE;
|
||||||
// declare with extra bytes so we can print the version number into it
|
// declare with extra bytes so we can print the version number into it
|
||||||
char helptext_center[88] =
|
char helptext_center[88] =
|
||||||
"imv(stb)\n"
|
"imv(stb)\n"
|
||||||
"Copyright 2007 Sean Barret\n"
|
"Copyright 2007 Sean Barrett\n"
|
||||||
"http://code.google.com/p/stb-imv\n"
|
"http://code.google.com/p/stb-imv\n"
|
||||||
"version "
|
"version "
|
||||||
;
|
;
|
||||||
|
@ -556,8 +556,8 @@ char helptext_left[] =
|
||||||
" (CTRL-) O: open image\n"
|
" (CTRL-) O: open image\n"
|
||||||
" P: change preferences\n"
|
" P: change preferences\n"
|
||||||
" F: toggle frame\n"
|
" F: toggle frame\n"
|
||||||
"SHIFT-F: toggle white stripe in frame\n"
|
"SHIFT-F: toggle frame but keep stripe\n"
|
||||||
"CTRL-F: toggle both\n"
|
" CTRL-F: toggle white stripe in frame\n"
|
||||||
" L: toggle filename label\n"
|
" L: toggle filename label\n"
|
||||||
"F1, H, ?: help"
|
"F1, H, ?: help"
|
||||||
;
|
;
|
||||||
|
@ -1110,7 +1110,7 @@ void init_filelist(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
image_files = stb_readdir_files_mask(path_to_file, "*.jpg;*.jpeg;*.png;*.bmp");
|
image_files = stb_readdir_files_mask(path_to_file, "*.jpg;*.jpeg;*.png;*.bmp");
|
||||||
if (image_files == NULL) error("Error: couldn't read directory.");
|
if (image_files == NULL) { error("Error: couldn't read directory."); exit(0); }
|
||||||
|
|
||||||
// given the array of filenames, build an equivalent fileinfo array
|
// given the array of filenames, build an equivalent fileinfo array
|
||||||
stb_arr_setlen(fileinfo, stb_arr_len(image_files));
|
stb_arr_setlen(fileinfo, stb_arr_len(image_files));
|
||||||
|
@ -1623,58 +1623,51 @@ void mouse(UINT ev, int x, int y)
|
||||||
static unsigned int physmem; // available physical memory according to GlobalMemoryStatus
|
static unsigned int physmem; // available physical memory according to GlobalMemoryStatus
|
||||||
|
|
||||||
char *reg_root = "Software\\SilverSpaceship\\imv";
|
char *reg_root = "Software\\SilverSpaceship\\imv";
|
||||||
|
HKEY zreg;
|
||||||
|
|
||||||
int reg_get(char *str, void *data, int len)
|
int reg_get(char *str, void *data, int len)
|
||||||
{
|
{
|
||||||
static char buffer[128];
|
unsigned int type;
|
||||||
int result=0;
|
if (ERROR_SUCCESS == RegQueryValueEx(zreg, str, 0, &type, data, &len))
|
||||||
HKEY z=0;
|
if (type == REG_BINARY)
|
||||||
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_root, 0, KEY_READ, &z))
|
return TRUE;
|
||||||
{
|
return FALSE;
|
||||||
unsigned int type;
|
|
||||||
if (ERROR_SUCCESS == RegQueryValueEx(z, str, 0, &type, data, &len))
|
|
||||||
if (type == REG_BINARY)
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
if (z)
|
|
||||||
RegCloseKey(z);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int reg_set(char *str, void *data, int len)
|
int reg_set(char *str, void *data, int len)
|
||||||
{
|
{
|
||||||
int result = 0;
|
return (ERROR_SUCCESS == RegSetValueEx(zreg, str, 0, REG_BINARY, data, len));
|
||||||
HKEY z=0;
|
|
||||||
if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, reg_root, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &z, NULL))
|
|
||||||
{
|
|
||||||
if (ERROR_SUCCESS == RegSetValueEx(z, str, 0, REG_BINARY, data, len))
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
if (z)
|
|
||||||
RegCloseKey(z);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we use very short strings for these to avoid wasting space, since
|
// we use very short strings for these to avoid wasting space, since
|
||||||
// people shouldn't be mucking with them directly anyway!
|
// people shouldn't be mucking with them directly anyway!
|
||||||
void reg_save(void)
|
void reg_save(void)
|
||||||
{
|
{
|
||||||
int temp = max_cache_bytes >> 20;
|
if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, reg_root, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &zreg, NULL))
|
||||||
reg_set("ac", &alpha_background, 6);
|
{
|
||||||
reg_set("up", &upsample_cubic, 4);
|
int temp = max_cache_bytes >> 20;
|
||||||
reg_set("cache", &temp, 4);
|
reg_set("ac", &alpha_background, 6);
|
||||||
reg_set("lfs", &label_font_height, 4);
|
reg_set("up", &upsample_cubic, 4);
|
||||||
reg_set("label", &show_label, 4);
|
reg_set("cache", &temp, 4);
|
||||||
|
reg_set("lfs", &label_font_height, 4);
|
||||||
|
reg_set("label", &show_label, 4);
|
||||||
|
RegCloseKey(zreg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reg_load(void)
|
void reg_load(void)
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
reg_get("ac", &alpha_background, 6);
|
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_root, 0, KEY_READ, &zreg))
|
||||||
reg_get("up", &upsample_cubic, 4);
|
{
|
||||||
reg_get("lfs", &label_font_height, 4);
|
reg_get("ac", &alpha_background, 6);
|
||||||
reg_get("label", &show_label, 4);
|
reg_get("up", &upsample_cubic, 4);
|
||||||
if (reg_get("cache", &temp, 4))
|
reg_get("lfs", &label_font_height, 4);
|
||||||
max_cache_bytes = temp << 20;
|
reg_get("label", &show_label, 4);
|
||||||
|
if (reg_get("cache", &temp, 4))
|
||||||
|
max_cache_bytes = temp << 20;
|
||||||
|
RegCloseKey(zreg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HWND dialog; // preferences dialog
|
static HWND dialog; // preferences dialog
|
||||||
|
@ -1957,8 +1950,13 @@ int WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
| (GetKeyState(VK_CONTROL) < 0 ? MY_CTRL : 0);
|
| (GetKeyState(VK_CONTROL) < 0 ? MY_CTRL : 0);
|
||||||
code += wParam;
|
code += wParam;
|
||||||
switch (wParam) {
|
switch (wParam) {
|
||||||
|
|
||||||
case 27:
|
case 27:
|
||||||
exit(0);
|
if (!show_help)
|
||||||
|
exit(0);
|
||||||
|
show_help = !show_help;
|
||||||
|
InvalidateRect(win, NULL, FALSE);
|
||||||
|
break;
|
||||||
|
|
||||||
case ' ': // space
|
case ' ': // space
|
||||||
advance(1);
|
advance(1);
|
||||||
|
@ -2004,17 +2002,17 @@ int WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
InvalidateRect(win, NULL, FALSE);
|
InvalidateRect(win, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F' | MY_SHIFT:
|
case 'F' | MY_CTRL:
|
||||||
extra_border = !extra_border;
|
extra_border = !extra_border;
|
||||||
if (cur) frame(cur);
|
if (cur) frame(cur);
|
||||||
InvalidateRect(win, NULL, FALSE);
|
InvalidateRect(win, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F':
|
case 'F' | MY_SHIFT:
|
||||||
toggle_frame();
|
toggle_frame();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F' | MY_CTRL:
|
case 'F':
|
||||||
toggle_frame();
|
toggle_frame();
|
||||||
extra_border = show_frame;
|
extra_border = show_frame;
|
||||||
if (cur) frame(cur);
|
if (cur) frame(cur);
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
Version 0.93: Beta 4
|
||||||
|
* bugfix: alter stb_image to support jpegs with weird header blocks
|
||||||
|
* bugfix: exit after printing directory error message
|
||||||
|
* bugfix: change naming of frame/border variables
|
||||||
|
* bugfix: ESC when showing help clears help, rather than exiting
|
||||||
|
* internal: clean up registry code to halve registry ops
|
||||||
|
|
||||||
Version 0.92: Beta 3
|
Version 0.92: Beta 3
|
||||||
* internal: replace Sleep()-based thread-joining code with synchronization primitive
|
* internal: replace Sleep()-based thread-joining code with synchronization primitive
|
||||||
* internal: change work queue internals to use stb_mutex
|
* internal: change work queue internals to use stb_mutex
|
||||||
|
|
17
stb_image.c
17
stb_image.c
|
@ -1,4 +1,4 @@
|
||||||
/* stbi-0.94 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
|
/* stbi-0.95 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c
|
||||||
when you control the images you're loading
|
when you control the images you're loading
|
||||||
|
|
||||||
QUICK NOTES:
|
QUICK NOTES:
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
PSD loader
|
PSD loader
|
||||||
|
|
||||||
history:
|
history:
|
||||||
|
0.95 during header scan, seek to markers in case of padding
|
||||||
0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same
|
0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same
|
||||||
0.93 handle jpegtran output; verbose errors
|
0.93 handle jpegtran output; verbose errors
|
||||||
0.92 read 4,8,16,24,32-bit BMP files of several formats
|
0.92 read 4,8,16,24,32-bit BMP files of several formats
|
||||||
|
@ -333,6 +334,15 @@ static int get8(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int at_eof(void)
|
||||||
|
{
|
||||||
|
#ifndef STBI_NO_STDIO
|
||||||
|
if (img_file)
|
||||||
|
return feof(img_file);
|
||||||
|
#endif
|
||||||
|
return img_buffer >= img_buffer_end;
|
||||||
|
}
|
||||||
|
|
||||||
static uint8 get8u(void)
|
static uint8 get8u(void)
|
||||||
{
|
{
|
||||||
return (uint8) get8();
|
return (uint8) get8();
|
||||||
|
@ -1072,6 +1082,11 @@ static int decode_jpeg_header(int scan)
|
||||||
while (!SOF(m)) {
|
while (!SOF(m)) {
|
||||||
if (!process_marker(m)) return 0;
|
if (!process_marker(m)) return 0;
|
||||||
m = get_marker();
|
m = get_marker();
|
||||||
|
while (m == MARKER_none) {
|
||||||
|
// some files have extra padding after their blocks, so ok, we'll scan
|
||||||
|
if (at_eof()) return e("no SOF", "Corrupt JPEG");
|
||||||
|
m = get_marker();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!process_frame_header(scan)) return 0;
|
if (!process_frame_header(scan)) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
set VERSION="0.92"
|
set VERSION="0.93"
|
||||||
|
|
Loading…
Reference in New Issue