mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 20:40:28 +00:00
Add more documentation to redbean
This change also improves the unix module, adding a reboot() system call for fun and profit, fixing the execve() api, and a printimage release.
This commit is contained in:
parent
87396f43bc
commit
9bfa6ec06e
16 changed files with 498 additions and 133 deletions
|
@ -53,12 +53,15 @@
|
|||
#include "third_party/stb/stb_image.h"
|
||||
#include "tool/viz/lib/graphic.h"
|
||||
|
||||
STATIC_YOINK("__zipos_get");
|
||||
|
||||
static struct Flags {
|
||||
const char *out;
|
||||
bool subpixel;
|
||||
bool unsharp;
|
||||
bool dither;
|
||||
bool ruler;
|
||||
bool magikarp;
|
||||
bool trailingnewline;
|
||||
long half;
|
||||
bool full;
|
||||
|
@ -85,6 +88,7 @@ FLAGS\n\
|
|||
-f display full size\n\
|
||||
-s unsharp sharpening\n\
|
||||
-x xterm256 color mode\n\
|
||||
-m use magikarp scaling\n\
|
||||
-d hilbert curve dithering\n\
|
||||
-r display pixel ruler on sides\n\
|
||||
-p convert to subpixel layout\n\
|
||||
|
@ -94,7 +98,6 @@ FLAGS\n\
|
|||
EXAMPLES\n\
|
||||
\n\
|
||||
printimage.com -sxd lemurs.jpg # 256-color dither unsharp\n\
|
||||
\n\
|
||||
\n");
|
||||
exit(rc);
|
||||
}
|
||||
|
@ -118,7 +121,7 @@ static void GetOpts(int *argc, char *argv[]) {
|
|||
(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-help") == 0)) {
|
||||
PrintUsage(EXIT_SUCCESS, stdout);
|
||||
}
|
||||
while ((opt = getopt(*argc, argv, "?vpfrtxads234o:w:h:")) != -1) {
|
||||
while ((opt = getopt(*argc, argv, "?vpmfrtxads234o:w:h:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
g_flags.out = optarg;
|
||||
|
@ -146,6 +149,9 @@ static void GetOpts(int *argc, char *argv[]) {
|
|||
case 'r':
|
||||
g_flags.ruler = true;
|
||||
break;
|
||||
case 'm':
|
||||
g_flags.magikarp = true;
|
||||
break;
|
||||
case 'p':
|
||||
g_flags.subpixel = true;
|
||||
break;
|
||||
|
@ -173,10 +179,6 @@ static void GetOpts(int *argc, char *argv[]) {
|
|||
PrintUsage(EX_USAGE, stderr);
|
||||
}
|
||||
}
|
||||
if (optind == *argc) {
|
||||
if (!g_flags.out) g_flags.out = "-";
|
||||
argv[(*argc)++] = "-";
|
||||
}
|
||||
if (!g_flags.full && (!g_flags.width || !g_flags.width)) {
|
||||
ws.ws_col = 80;
|
||||
ws.ws_row = 24;
|
||||
|
@ -398,6 +400,22 @@ void WithImageFile(const char *path,
|
|||
sxn = xn;
|
||||
dyn = g_flags.height;
|
||||
dxn = g_flags.width;
|
||||
if (g_flags.magikarp) {
|
||||
while (HALF(syn) > dyn || HALF(sxn) > dxn) {
|
||||
if (HALF(sxn) > dxn) {
|
||||
Magikarp2xX(yn, xn, data, syn, sxn);
|
||||
Magikarp2xX(yn, xn, (char *)data + yn * xn, syn, sxn);
|
||||
Magikarp2xX(yn, xn, (char *)data + yn * xn * 2, syn, sxn);
|
||||
sxn = HALF(sxn);
|
||||
}
|
||||
if (HALF(syn) > dyn) {
|
||||
Magikarp2xY(yn, xn, data, syn, sxn);
|
||||
Magikarp2xY(yn, xn, (char *)data + yn * xn, syn, sxn);
|
||||
Magikarp2xY(yn, xn, (char *)data + yn * xn * 2, syn, sxn);
|
||||
syn = HALF(syn);
|
||||
}
|
||||
}
|
||||
}
|
||||
data = EzGyarados(3, dyn, dxn, gc(memalign(32, dyn * dxn * 3)), cn, yn, xn,
|
||||
data, 0, cn, dyn, dxn, syn, sxn, 0, 0, 0, 0);
|
||||
yn = dyn;
|
||||
|
@ -410,6 +428,7 @@ int main(int argc, char *argv[]) {
|
|||
int i;
|
||||
ShowCrashReports();
|
||||
GetOpts(&argc, argv);
|
||||
if (optind == argc) PrintUsage(0, stdout);
|
||||
stbi_set_unpremultiply_on_load(true);
|
||||
for (i = optind; i < argc; ++i) {
|
||||
WithImageFile(argv[i], ProcessImage);
|
||||
|
|
|
@ -45,6 +45,7 @@ TOOL_VIZ_DIRECTDEPS = \
|
|||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
LIBC_ZIPOS \
|
||||
NET_HTTP \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_GDTOA \
|
||||
|
@ -71,6 +72,25 @@ o/$(MODE)/tool/viz/%.com.dbg: \
|
|||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
o/$(MODE)/tool/viz/printimage.com.dbg: \
|
||||
$(TOOL_VIZ_DEPS) \
|
||||
o/$(MODE)/tool/viz/printimage.o \
|
||||
o/$(MODE)/tool/viz/viz.pkg \
|
||||
o/$(MODE)/LICENSE.zip.o \
|
||||
$(CRT) \
|
||||
$(APE_NO_MODIFY_SELF)
|
||||
@$(APELINK)
|
||||
|
||||
o/$(MODE)/tool/viz/printimage.com: \
|
||||
o/$(MODE)/tool/viz/printimage.com.dbg \
|
||||
o/$(MODE)/third_party/zip/zip.com \
|
||||
o/$(MODE)/tool/build/symtab.com
|
||||
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
|
||||
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com \
|
||||
-o o/$(MODE)/tool/viz/.printimage/.symtab $<
|
||||
@$(COMPILE) -AZIP -T$@ o/$(MODE)/third_party/zip/zip.com -9qj $@ \
|
||||
o/$(MODE)/tool/viz/.printimage/.symtab
|
||||
|
||||
o/$(MODE)/tool/viz/printvideo.com: \
|
||||
o/$(MODE)/tool/viz/printvideo.com.dbg \
|
||||
o/$(MODE)/third_party/zip/zip.com \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue