Compare commits
117 Commits
0.6.2
...
v0.8.0-pre
Author | SHA1 | Date | |
---|---|---|---|
3d89e94823 | |||
228d0088fb | |||
86465b5f76 | |||
6af08275e9 | |||
3c7c12ef39 | |||
404761d712 | |||
83d948ef24 | |||
946deb210d | |||
c2cdf256ba | |||
f0f4a64dfc | |||
25ced38cba | |||
86166f87eb | |||
54cce27a34 | |||
4d6a24f51f | |||
2e6d2c3cd5 | |||
7f62666017 | |||
8b3173811a | |||
b40f6d738e | |||
d4f12cb9b0 | |||
690dd1d6ca | |||
c21e8192d4 | |||
d4878d4e3d | |||
0503fe7e5b | |||
cd20f32acb | |||
c0fe7eaab5 | |||
f1b712af4a | |||
3231bc8240 | |||
8f80a99fc6 | |||
2cc908b043 | |||
d07d2a246a | |||
bf51ecda77 | |||
d87235c4b5 | |||
6c22b58487 | |||
05835a5c07 | |||
fa948a7beb | |||
04741198e2 | |||
5fb7ca78a9 | |||
ce0d83912e | |||
26eb9b4970 | |||
02ea4c6b4b | |||
0d35167c90 | |||
51ab42a9b0 | |||
4ca9e96276 | |||
b71b359502 | |||
a75f37c2d4 | |||
a7a44b39dc | |||
f6eb34ed78 | |||
099f21345f | |||
c1876482f7 | |||
a70f243421 | |||
b100891c34 | |||
2f4e78b138 | |||
5163f19796 | |||
c3f737de14 | |||
809b0cfad6 | |||
cacf83d434 | |||
ca1e242997 | |||
165b3b347f | |||
2965c3945a | |||
8d28ae3754 | |||
7d327f22aa | |||
d0c2123996 | |||
6081c4d310 | |||
0dfb37cc1c | |||
f15e457947 | |||
5d3db56ee4 | |||
8bec3356e5 | |||
3b4e541d0e | |||
b03633e010 | |||
651a43574f | |||
8e7bee4ea2 | |||
db66485432 | |||
12d47e5482 | |||
39c1a0f991 | |||
3f548f2d09 | |||
6587d22d2c | |||
76da1a033f | |||
6c530c44bd | |||
85fa45201e | |||
10d4ad6fd5 | |||
d5a3da2c35 | |||
a8b0540ecc | |||
cc5579971d | |||
6123bd3307 | |||
ed0d9998ff | |||
483efd280a | |||
1e2b4c0476 | |||
3992096df3 | |||
7165d1edc4 | |||
27653c2350 | |||
67ecd0ceff | |||
de74aac8af | |||
e1e0d1cbd5 | |||
b6051242a2 | |||
ea778c004b | |||
b5dbe5ce78 | |||
7645b45992 | |||
c0bf1c7bf1 | |||
49805784b0 | |||
8b7b12007b | |||
88b329f1d0 | |||
5fbbae9f99 | |||
520eec7c9c | |||
f75078b42b | |||
16ef0ff65a | |||
fed723aa48 | |||
6813c50c12 | |||
3c18129f94 | |||
409161efe7 | |||
8e7958be76 | |||
9e5ce455ca | |||
94e90a3cd8 | |||
58b4667ec7 | |||
97aff8615a | |||
e57c15bddb | |||
82d8005529 | |||
acc0bdfd87 |
19
.github/workflows/Docs.yml
vendored
19
.github/workflows/Docs.yml
vendored
@ -2,7 +2,7 @@ name: 📄
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "**" ]
|
||||
branches: [ "!*" ]
|
||||
pull_request:
|
||||
branches: [ "*" ]
|
||||
|
||||
@ -26,24 +26,25 @@ jobs:
|
||||
# Runs a single command using the runners shell
|
||||
- name: Run a one-line script
|
||||
run: |
|
||||
git config --global user.email "tobid7@outlook.de"
|
||||
git config --global user.name "Tobi-D7"
|
||||
sudo apt-get install doxygen cmake -y
|
||||
doxygen
|
||||
echo done
|
||||
ls -r
|
||||
cd ..
|
||||
git clone https://github.com/NPI-D7/NPI-D7.github.io.git
|
||||
mkdir -p NPI-D7.github.io/${{ steps.branch.outputs.branch }}
|
||||
#rm -r NPI-D7.github.io/${{ steps.branch.outputs.branch }}/*
|
||||
mv -v RenderD7/doc NPI-D7.github.io/${{ steps.branch.outputs.branch }}/
|
||||
git clone --depth 1 https://${{ secrets.TOKEN }}@github.com/NPI-D7/RenderD7.git RD7 -b gh-pages
|
||||
|
||||
mv -v RenderD7/doc/html/* RD7/
|
||||
#rm -r doc
|
||||
cd NPI-D7.github.io
|
||||
git config --global user.email "tobid7@outlook.de"
|
||||
git config --global user.name "Tobi-D7"
|
||||
cd RD7
|
||||
|
||||
echo tobid7
|
||||
git stage *
|
||||
|
||||
echo staged
|
||||
git commit -m "Documentation1"
|
||||
git tag doc
|
||||
echo commited
|
||||
git push origin main
|
||||
git push origin gh-pages
|
||||
echo pushed
|
||||
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
release/
|
||||
debug/
|
||||
lib/
|
||||
*.bz2
|
8
Doxyfile
8
Doxyfile
@ -1157,7 +1157,7 @@ HTML_FILE_EXTENSION = .html
|
||||
# of the possible markers and block names see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_HEADER =
|
||||
HTML_HEADER =
|
||||
|
||||
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
|
||||
# generated HTML page. If the tag is left blank doxygen will generate a standard
|
||||
@ -1167,7 +1167,7 @@ HTML_HEADER =
|
||||
# that doxygen normally uses.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_FOOTER =
|
||||
HTML_FOOTER =
|
||||
|
||||
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
|
||||
# sheet that is used by each HTML page. It can be used to fine-tune the look of
|
||||
@ -1192,7 +1192,7 @@ HTML_STYLESHEET =
|
||||
# list). For an example see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_EXTRA_STYLESHEET = doxygen.css
|
||||
HTML_EXTRA_STYLESHEET = docsn.css
|
||||
|
||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||
# other source files which should be copied to the HTML output directory. Note
|
||||
@ -1202,7 +1202,7 @@ HTML_EXTRA_STYLESHEET = doxygen.css
|
||||
# files will be copied as-is; there are no commands or markers available.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_EXTRA_FILES =
|
||||
HTML_EXTRA_FILES =
|
||||
|
||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||
# will adjust the colors in the style sheet and background images according to
|
||||
|
205
Makefile
Normal file
205
Makefile
Normal file
@ -0,0 +1,205 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
export renderd7_MAJOR := 0
|
||||
export renderd7_MINOR := 8
|
||||
export renderd7_PATCH := 0
|
||||
|
||||
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
|
||||
|
||||
# If on a tagged commit, use the tag instead of the commit
|
||||
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
|
||||
GIT_VER := $(shell git tag -l --points-at HEAD)
|
||||
else
|
||||
GIT_VER := $(shell git rev-parse --short HEAD)
|
||||
endif
|
||||
|
||||
TIME_TIME := $(shell date --iso=seconds)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := renderd7
|
||||
SOURCES := source external/source external/libnsbmp/source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
|
||||
CFLAGS := -g -Wall -Werror -mword-relocations -save-temps\
|
||||
-DV_STRING=\"$(GIT_VER)\" \
|
||||
-DV_TIME=\"$(TIME_TIME)\" \
|
||||
-ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(BUILD_CFLAGS)
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
||||
|
||||
ASFLAGS := -g $(ARCH) $(DEFINES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
||||
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
||||
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
|
||||
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
||||
|
||||
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I.
|
||||
|
||||
.PHONY: clean all doc
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: lib/librenderd7.a lib/librenderd7d.a
|
||||
|
||||
doc:
|
||||
@doxygen Doxyfile
|
||||
|
||||
dist-bin: all
|
||||
@tar --exclude=*~ -cjf $(TARGET)-$(VERSION).tar.bz2 include lib
|
||||
|
||||
dist-src:
|
||||
@tar --exclude=*~ -cjf $(TARGET)-src-$(VERSION).tar.bz2 include $(SOURCES) Makefile
|
||||
|
||||
dist: dist-src dist-bin
|
||||
|
||||
install: dist-bin
|
||||
mkdir -p $(DEPSDIR)$(DEVKITPRO)/libctru
|
||||
bzip2 -cd $(TARGET)-$(VERSION).tar.bz2 | tar -xf - -C $(DEPSDIR)$(DEVKITPRO)/libctru
|
||||
|
||||
lib:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
release:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
debug:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
|
||||
lib/librenderd7.a : lib release $(SOURCES) $(INCLUDES)
|
||||
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
||||
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
|
||||
DEPSDIR=$(CURDIR)/release \
|
||||
--no-print-directory -C release \
|
||||
-f $(CURDIR)/Makefile
|
||||
|
||||
lib/librenderd7d.a : lib debug $(SOURCES) $(INCLUDES)
|
||||
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
|
||||
BUILD_CFLAGS="-DDEBUG=1 -Og" \
|
||||
DEPSDIR=$(CURDIR)/debug \
|
||||
--no-print-directory -C debug \
|
||||
-f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr release debug lib includes
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT) : $(OFILES)
|
||||
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# rules for assembling GPU shaders
|
||||
#---------------------------------------------------------------------------------
|
||||
define shader-as
|
||||
$(eval CURBIN := $*.shbin)
|
||||
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
|
||||
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
picasso -o $(CURBIN) $1
|
||||
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
|
||||
endef
|
||||
|
||||
%.shbin.o %_shbin.h : %.v.pica %.g.pica
|
||||
@echo $(notdir $^)
|
||||
@$(call shader-as,$^)
|
||||
|
||||
%.shbin.o %_shbin.h : %.v.pica
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$<)
|
||||
|
||||
%.shbin.o %_shbin.h : %.shlist
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
18
README.md
18
README.md
@ -1,2 +1,18 @@
|
||||
# RenderD7 (https://npi-d7.github.io/RenderD7/main/doc/html/index.html)
|
||||
# RenderD7
|
||||
RenderD7 is now LibRenderD7.
|
||||
### Installation (Ubuntu)
|
||||
first run this
|
||||
`sudo su`
|
||||
then this
|
||||
```
|
||||
git clone https://github.com/NPI-D7/RenderD7.git
|
||||
cd RenderD7
|
||||
export DEVKITARM=/opt/devkitpro/devkitARM/
|
||||
export DEVKITPRO=/opt/devkitpro/
|
||||
make install
|
||||
```
|
||||
Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
|
||||
|
||||
# RenderD7 (https://npi-d7.github.io/RenderD7/)
|
||||
Simple and Easey to use UI and Graphics helper.
|
||||
Create DOCS
|
||||
|
638
docsn.css
Normal file
638
docsn.css
Normal file
@ -0,0 +1,638 @@
|
||||
/* This doxygen theme is free to use. If you like this, please Star https://github.com/kcwongjoe/doxygen_theme_flat_design */
|
||||
|
||||
/* Color Pattern. You can change this pattern to design your theme. */
|
||||
|
||||
:root {
|
||||
/* Content */
|
||||
--bgcolor: #ffffff;
|
||||
--bgfont: #303030;
|
||||
--bgfont2: #f3c60a;
|
||||
--bgfont-hover: #f3c60a;
|
||||
--bgfont-hover-text-decoration: none;
|
||||
--bgborder: #7d7d7d;
|
||||
--bgborder2: #f6f6f6;
|
||||
/* Main Header */
|
||||
--bg1color: #303030;
|
||||
--bg1font: #ffffff;
|
||||
--bg1font2: #f3c60a;
|
||||
/* Second header */
|
||||
--bg2color: #E2E2E2;
|
||||
--bg2font: #7D7D7D;
|
||||
--bg2-hover-bg: #ffffff;
|
||||
--bg2-hover-font: #303030;
|
||||
--bg2-hover-topborder: #f3c60a;
|
||||
/* Third header */
|
||||
--bg3color: #f6f6f6;
|
||||
--bg3font: #303030;
|
||||
--bg3font2: #7D7D7D;
|
||||
/* Code */
|
||||
--code-bg: #f6f6f6;
|
||||
--code-comment: #7D7D7D;
|
||||
--code-keyword: #d73a49;
|
||||
--code-preprocessor: #d73a49;
|
||||
--code-keywordtype: #d73a49;
|
||||
--code-text: #303030;
|
||||
--code-code: #6f42c1;
|
||||
--code-line: #7D7D7D;
|
||||
--code-line-bg: #D8D8D8;
|
||||
/* Namespace List, Class List icon */
|
||||
--icon-bg: #303030;
|
||||
--icon-font: #f3c60a;
|
||||
/* Class Index */
|
||||
--qindex-menu-bg: #303030;
|
||||
--qindex-menu-font: #ffffff;
|
||||
--qindex-menu-font-hover: #f3c60a;
|
||||
--qindex-icon-bg: #f3c60a;
|
||||
--qindex-icon-font: #303030;
|
||||
/* Member table */
|
||||
--mem-title-bg: #303030;
|
||||
--mem-title-font: #ffffff;
|
||||
--mem-subtitle-bg: #f3c60a;
|
||||
--mem-subtitle-font: #303030;
|
||||
--mem-subtitle-font-hover: #303030;
|
||||
--mem-content-bg: #ffffff;
|
||||
--mem-content-font: #303030;
|
||||
--mem-content-border: #f6f6f6;
|
||||
/* Nav Tree */
|
||||
--nav-tree-bg: #E2E2E2;
|
||||
--nav-tree-bg-hover: #ffffff;
|
||||
--nav-tree-font: #7D7D7D;
|
||||
--nav-tree-font-hover: #303030;
|
||||
--nav-tree-bg-selected: #f3c60a;
|
||||
--nav-tree-font-selected: #303030;
|
||||
}
|
||||
|
||||
body, table, div, p, dl {
|
||||
color: var(--bgfont);
|
||||
background-color: var(--bgcolor);
|
||||
line-height: 150%;
|
||||
font: 14px/22px, Roboto, Arial;
|
||||
}
|
||||
|
||||
div.contents {
|
||||
margin: 20px 40px;
|
||||
}
|
||||
|
||||
div.contents ul {
|
||||
line-height: 200%;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/********** Project header *********/
|
||||
|
||||
/***********************************/
|
||||
|
||||
#titlearea {
|
||||
border-bottom: none;
|
||||
padding-bottom: 20px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
#titlearea, #titlearea * {
|
||||
color: var(--bg1font);
|
||||
background-color: var(--bg1color);
|
||||
}
|
||||
|
||||
#projectname {
|
||||
padding: 0px 40px !important;
|
||||
}
|
||||
|
||||
#projectbrief {
|
||||
padding: 0px 40px !important;
|
||||
}
|
||||
|
||||
#projectalign {
|
||||
padding: 0px !important;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************ Main Menu ************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
/* Margin */
|
||||
|
||||
#main-menu {
|
||||
padding: 0px 30px;
|
||||
}
|
||||
|
||||
#main-menu a, #main-menu a:hover {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
/* Menu button */
|
||||
|
||||
#main-menu li a {
|
||||
background-image: none;
|
||||
font-family: Arial;
|
||||
text-transform: uppercase;
|
||||
text-shadow: none;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
#main-menu, #main-menu>li>a {
|
||||
background-image: none;
|
||||
background-color: var(--bg2color);
|
||||
color: var(--bg2font);
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
/* hover Effect */
|
||||
|
||||
#main-menu>li {
|
||||
border-top: 5px solid var(--bg2color);
|
||||
}
|
||||
|
||||
#main-menu>li:hover {
|
||||
color: var(--bg2-hover-font);
|
||||
background-color: var(--bg2-hover-bg);
|
||||
border-top: 5px solid var(--bg2-hover-topborder);
|
||||
}
|
||||
|
||||
#main-menu>li:hover, #main-menu>li>a:hover, #main-menu>li>a.highlighted {
|
||||
color: var(--bg2-hover-font);
|
||||
background-color: var(--bg2-hover-bg);
|
||||
}
|
||||
|
||||
/* Search Bar */
|
||||
|
||||
#MSearchBox {
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#MSearchBox>span {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#main-menu>li:last-child {
|
||||
padding: 25px 0px;
|
||||
}
|
||||
|
||||
/* Reset search hover color*/
|
||||
|
||||
#main-menu>li:last-child:hover {
|
||||
color: var(--bg2font);
|
||||
background-color: var(--bg2color);
|
||||
border-top: 5px solid var(--bg2color);
|
||||
}
|
||||
|
||||
#MSearchResultsWindow {
|
||||
border: 1px solid var(--bg3font2);
|
||||
background-color: var(--bg3color);
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
body.SRPage, body.SRPage * {
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
/* Sub Menu */
|
||||
|
||||
#main-menu>li ul {
|
||||
transition: max-height 0.2s ease-in-out;
|
||||
padding: 0px;
|
||||
border-radius: 0px !important;
|
||||
}
|
||||
|
||||
#main-menu>li ul:before, #main-menu>li ul:after {
|
||||
border-width: 0px;
|
||||
}
|
||||
|
||||
#main-menu>li>ul li a, #main-menu>li>ul li {
|
||||
background-color: var(--bgcolor);
|
||||
color: var(--bgfont);
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
#main-menu>li>ul li a:hover, #main-menu>li>ul li:hover {
|
||||
background-color: var(--bgfont2);
|
||||
color: var(--bgfont);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************** Header *************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
div.headertitle {
|
||||
padding: 5px 40px;
|
||||
}
|
||||
|
||||
div.header, div.header * {
|
||||
color: var(--bg3font);
|
||||
background-color: var(--bg3color);
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
div.summary {
|
||||
padding-right: 40px;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************** Link *************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
a, a:visited, a:active, .contents a:visited, body.SRPage a, body.SRPage a:visited, body.SRPage a:active {
|
||||
color: var(--bgfont);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover, .contents a:hover, body.SRPage a:hover {
|
||||
color: var(--bgfont-hover);
|
||||
text-decoration: var(--bgfont-hover-text-decoration);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************ Nav-path ************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
#nav-path, #nav-path ul {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
#nav-path ul {
|
||||
padding: 5px 30px;
|
||||
}
|
||||
|
||||
#nav-path, #nav-path * {
|
||||
color: var(--bg3font2);
|
||||
background-color: var(--bg3color);
|
||||
border: none;
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
li.navelem {
|
||||
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnN2Z2pzPSJodHRwOi8vc3ZnanMuY29tL3N2Z2pzIiB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgeD0iMCIgeT0iMCIgdmlld0JveD0iMCAwIDI5Mi4zNTkgMjkyLjM1OSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTEyIDUxMiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgY2xhc3M9IiI+PGc+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cgk8cGF0aCBkPSJNMjIyLjk3OSwxMzMuMzMxTDk1LjA3Myw1LjQyNEM5MS40NTYsMS44MDcsODcuMTc4LDAsODIuMjI2LDBjLTQuOTUyLDAtOS4yMzMsMS44MDctMTIuODUsNS40MjQgICBjLTMuNjE3LDMuNjE3LTUuNDI0LDcuODk4LTUuNDI0LDEyLjg0N3YyNTUuODEzYzAsNC45NDgsMS44MDcsOS4yMzIsNS40MjQsMTIuODQ3YzMuNjIxLDMuNjE3LDcuOTAyLDUuNDI4LDEyLjg1LDUuNDI4ICAgYzQuOTQ5LDAsOS4yMy0xLjgxMSwxMi44NDctNS40MjhsMTI3LjkwNi0xMjcuOTA3YzMuNjE0LTMuNjEzLDUuNDI4LTcuODk3LDUuNDI4LTEyLjg0NyAgIEMyMjguNDA3LDE0MS4yMjksMjI2LjU5NCwxMzYuOTQ4LDIyMi45NzksMTMzLjMzMXoiIGZpbGw9IiM3ZDdkN2QiIGRhdGEtb3JpZ2luYWw9IiMwMDAwMDAiIHN0eWxlPSIiIGNsYXNzPSIiPjwvcGF0aD4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8L2c+PC9zdmc+);
|
||||
background-size: 9px;
|
||||
}
|
||||
|
||||
li.navelem a {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/*************** mem ***************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
.memtitle {
|
||||
padding: 15px;
|
||||
margin-top: 30px;
|
||||
border-top-left-radius: 0px;
|
||||
border-top-right-radius: 0px;
|
||||
}
|
||||
|
||||
.memtitle, .memtitle *, .memtitle a:visited {
|
||||
border: none;
|
||||
background-image: none;
|
||||
color: var(--mem-title-font);
|
||||
background-color: var(--mem-title-bg);
|
||||
}
|
||||
|
||||
.memproto {
|
||||
padding: 10px;
|
||||
text-shadow: none;
|
||||
padding: 20px;
|
||||
border-top-right-radius: 0px;
|
||||
-moz-border-radius-topright: 0px;
|
||||
-webkit-border-top-right-radius: 0px;
|
||||
}
|
||||
|
||||
.memproto, .memproto *, .memproto a:visited {
|
||||
border: none;
|
||||
background-image: none;
|
||||
background-color: var(--mem-subtitle-bg);
|
||||
color: var(--mem-subtitle-font);
|
||||
font-size: inherit;
|
||||
line-height: 100%
|
||||
}
|
||||
|
||||
.memproto a:hover {
|
||||
color: var(--mem-subtitle-font-hover);
|
||||
}
|
||||
|
||||
.memdoc {
|
||||
border-bottom: 1px solid var(--mem-content-border);
|
||||
border-left: 1px solid var(--mem-content-border);
|
||||
border-right: 1px solid var(--mem-content-border);
|
||||
background-color: var(--mem-content-bg);
|
||||
color: var(--mem-content-font);
|
||||
border-bottom-left-radius: 0px;
|
||||
border-bottom-right-radius: 0px;
|
||||
-moz-border-radius-bottomleft: 0px;
|
||||
-moz-border-radius-bottomright: 0px;
|
||||
-webkit-border-bottom-left-radius: 0px;
|
||||
-webkit-border-bottom-right-radius: 0px;
|
||||
}
|
||||
|
||||
.memdoc p, .memdoc dt {
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************* Contents ************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
a.anchor {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************* fragment ************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
h2.groupheader {
|
||||
color: #303030;
|
||||
font-size: 200%;
|
||||
font-weight: bold;
|
||||
border-bottom: none;
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
div.fragment, pre.fragment {
|
||||
border: none;
|
||||
padding: 20px;
|
||||
margin: none;
|
||||
background-color: var(--code-bg);
|
||||
}
|
||||
|
||||
div.line {
|
||||
background-color: var(--code-bg);
|
||||
}
|
||||
|
||||
span.comment {
|
||||
color: var(--code-comment);
|
||||
}
|
||||
|
||||
span.keyword {
|
||||
color: var(--code-keyword);
|
||||
}
|
||||
|
||||
span.preprocessor {
|
||||
color: var(--code-preprocessor);
|
||||
}
|
||||
|
||||
span.keywordtype {
|
||||
color: var(--code-keywordtype);
|
||||
}
|
||||
|
||||
span.mlabel {
|
||||
background-color: var(--code-text);
|
||||
color: var(--code-bg);
|
||||
border-top: none;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
border-bottom: none;
|
||||
padding: 10px;
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
a.code {
|
||||
color: var(--code-code);
|
||||
}
|
||||
|
||||
span.lineno, span.lineno>* {
|
||||
color: var(--code-line);
|
||||
border-right: none;
|
||||
background-color: var(--code-bg);
|
||||
}
|
||||
|
||||
span.lineno a {
|
||||
background-color: var(--code-line-bg);
|
||||
}
|
||||
|
||||
span.lineno a:hover {
|
||||
color: var(--bg3font);
|
||||
background-color: var(--code-line-bg);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************* directory ***********/
|
||||
|
||||
/***********************************/
|
||||
|
||||
.directory tr.even {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
.iconfclosed {
|
||||
background-image: url(closed-folder.png);
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.iconfopen {
|
||||
background-image: url(opened-folder.png);
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.icondoc {
|
||||
background-image: url(document.png);
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
color: #7d7d7d;
|
||||
}
|
||||
|
||||
.icona {
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
background-color: var(--icon-bg);
|
||||
color: var(--icon-font);
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
div.ah {
|
||||
background-color: var(--qindex-icon-bg);
|
||||
color: var(--qindex-icon-font);
|
||||
text-align: center;
|
||||
background-image: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
-webkit-border-radius: 0px;
|
||||
border-radius: 0px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
div.qindex {
|
||||
background-color: var(--qindex-menu-bg);
|
||||
border: none;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
a.qindex {
|
||||
color: var(--qindex-menu-font);
|
||||
font-weight: normal;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
a:hover.qindex {
|
||||
color: var(--qindex-menu-font-hover);
|
||||
}
|
||||
|
||||
a:visited.qindex {
|
||||
color: var(--qindex-menu-font);
|
||||
}
|
||||
|
||||
table.classindex {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
table.classindex a.el {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/************** footer *************/
|
||||
|
||||
/***********************************/
|
||||
|
||||
div.directory {
|
||||
border-top: 1px solid var(--bgborder);
|
||||
border-bottom: none;
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
div.directory a.el {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
div.directory>table {
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
hr.footer {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.contents>hr {
|
||||
border-top: 0px;
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/*********** memberdecls ***********/
|
||||
|
||||
/***********************************/
|
||||
|
||||
.memItemLeft, .memItemRight {
|
||||
padding: 15px 30px;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
.mdescRight {
|
||||
padding: 0px 30px 10px 30px;
|
||||
}
|
||||
|
||||
.memberdecls * {
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
.memSeparator {
|
||||
border-bottom: 1px solid var(--bgborder2);
|
||||
}
|
||||
|
||||
.memTemplParams {
|
||||
color: var(--bgfont);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/*********** nav-tree ***********/
|
||||
|
||||
/***********************************/
|
||||
|
||||
#nav-tree-contents {
|
||||
background-color: var(--nav-tree-bg);
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#side-nav, #nav-tree {
|
||||
background-image: none;
|
||||
background-color: var(--nav-tree-bg);
|
||||
}
|
||||
|
||||
#nav-tree .item {
|
||||
background-color: var(--nav-tree-bg);
|
||||
font-family: Arial;
|
||||
text-transform: uppercase;
|
||||
text-shadow: none;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
padding: 10px;
|
||||
color: var(--nav-tree-font);
|
||||
}
|
||||
|
||||
#nav-tree .arrow {
|
||||
color: var(--nav-tree-font);
|
||||
}
|
||||
|
||||
#nav-tree .selected {
|
||||
background-image: none;
|
||||
background-color: var(--nav-tree-bg-selected);
|
||||
}
|
||||
|
||||
#nav-tree .selected a {
|
||||
color: var(--nav-tree-font-selected);
|
||||
}
|
||||
|
||||
#nav-tree .item:hover {
|
||||
background-color: var(--nav-tree-bg-hover);
|
||||
color: var(--nav-tree-font-hover);
|
||||
}
|
||||
|
||||
#nav-tree .item a:hover {
|
||||
color: var(--nav-tree-font-hover);
|
||||
}
|
||||
|
||||
#side-nav .ui-resizable-e {
|
||||
background-image: none;
|
||||
background-color: var(--nav-tree-bg);
|
||||
}
|
||||
|
||||
#nav-sync {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#nav-sync>img {
|
||||
content: url(off_sync.png);
|
||||
}
|
||||
|
||||
#nav-sync.sync>img {
|
||||
content: url(on_sync.png);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
|
||||
/*********** Plant UML ***********/
|
||||
|
||||
/***********************************/
|
||||
|
||||
.plantumlgraph > img {
|
||||
width: 80%;
|
||||
}
|
1450
doxygen.css
1450
doxygen.css
File diff suppressed because it is too large
Load Diff
20
external/libnsbmp/COPYING
vendored
Normal file
20
external/libnsbmp/COPYING
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (C) 2006 Richard Wilson
|
||||
Copyright (C) 2008 Sean Fox
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
1388
external/libnsbmp/source/libnsbmp.c
vendored
Normal file
1388
external/libnsbmp/source/libnsbmp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
external/fs.c → external/source/fs.c
vendored
70
external/fs.c → external/source/fs.c
vendored
@ -1,8 +1,14 @@
|
||||
#include "external/fs.h"
|
||||
#include <renderd7/external/fs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WORKING_DIR "/"
|
||||
|
||||
void Utils_U8_To_U16(u16 *buf, const u8 *input, size_t bufsize) {
|
||||
ssize_t units = utf8_to_utf16(buf, input, bufsize);
|
||||
|
||||
@ -179,7 +185,7 @@ u64 FS_GetTotalStorage(FS_SystemMediaType media_type) {
|
||||
}
|
||||
|
||||
u64 FS_GetUsedStorage(FS_SystemMediaType media_type) {
|
||||
return (FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
|
||||
return 0;//(FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
|
||||
}
|
||||
|
||||
Result FS_RemoveFile(FS_Archive archive, const char *path) {
|
||||
@ -317,4 +323,64 @@ char *FS_GetFileTimestamp(const char *path) {
|
||||
return NULL;
|
||||
|
||||
return timeStr;
|
||||
}
|
||||
|
||||
FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
|
||||
*archive = ARCHIVE_SDMC;
|
||||
FS_Path filePath = {0};
|
||||
unsigned int prefixlen = 0;
|
||||
|
||||
if (!strncmp(path, "sdmc:/", 6)) {
|
||||
prefixlen = 5;
|
||||
} else if (*path != '/') {
|
||||
//if the path is local (doesnt start with a slash), it needs to be appended to the working dir to be valid
|
||||
char * actualPath = NULL;
|
||||
asprintf(&actualPath, "%s%s", WORKING_DIR, path);
|
||||
filePath = fsMakePath(PATH_ASCII, actualPath);
|
||||
free(actualPath);
|
||||
}
|
||||
|
||||
//if the filePath wasnt set above, set it
|
||||
if (filePath.size == 0) {
|
||||
filePath = fsMakePath(PATH_ASCII, path+prefixlen);
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
Result makeDirs(const char * path) {
|
||||
Result ret = 0;
|
||||
FS_ArchiveID archiveID;
|
||||
FS_Path filePath = getPathInfo(path, &archiveID);
|
||||
FS_Archive archive;
|
||||
|
||||
ret = FSUSER_OpenArchive(&archive, archiveID, fsMakePath(PATH_EMPTY, ""));
|
||||
|
||||
for (char * slashpos = strchr(path+1, '/'); slashpos != NULL; slashpos = strchr(slashpos+1, '/')) {
|
||||
char bak = *(slashpos);
|
||||
*(slashpos) = '\0';
|
||||
Handle dirHandle;
|
||||
|
||||
ret = FSUSER_OpenDirectory(&dirHandle, archive, filePath);
|
||||
if (R_SUCCEEDED(ret)) FSDIR_Close(dirHandle);
|
||||
else ret = FSUSER_CreateDirectory(archive, filePath, FS_ATTRIBUTE_DIRECTORY);
|
||||
|
||||
*(slashpos) = bak;
|
||||
}
|
||||
|
||||
FSUSER_CloseArchive(archive);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Result openFile(Handle* fileHandle, const char * path, bool write) {
|
||||
FS_ArchiveID archive;
|
||||
FS_Path filePath = getPathInfo(path, &archive);
|
||||
u32 flags = (write ? (FS_OPEN_CREATE | FS_OPEN_WRITE) : FS_OPEN_READ);
|
||||
|
||||
Result ret = 0;
|
||||
ret = makeDirs(strdup(path));
|
||||
ret = FSUSER_OpenFileDirectly(fileHandle, archive, fsMakePath(PATH_EMPTY, ""), filePath, flags, 0);
|
||||
if (write) ret = FSFILE_SetSize(*fileHandle, 0); //truncate the file to remove previous contents before writing
|
||||
|
||||
return ret;
|
||||
}
|
@ -28,7 +28,7 @@ The manual and changelog are in the header file "lodepng.h"
|
||||
Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.
|
||||
*/
|
||||
|
||||
#include "lodepng.h"
|
||||
#include <renderd7/external/lodepng.h>
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DISK
|
||||
#include <limits.h> /* LONG_MAX */
|
4
include/rd7.hpp
Normal file
4
include/rd7.hpp
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/bmp.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
@ -1,5 +1,5 @@
|
||||
#include <Time.hpp>
|
||||
|
||||
#pragma once
|
||||
#include <renderd7/Time.hpp>
|
||||
|
||||
namespace rnd7 {
|
||||
class Clock {
|
717
include/renderd7/bmp.hpp
Normal file
717
include/renderd7/bmp.hpp
Normal file
@ -0,0 +1,717 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
struct BMPFileHeader {
|
||||
uint16_t file_type{ 0x4D42 }; // File type always BM which is 0x4D42 (stored as hex uint16_t in little endian)
|
||||
uint32_t file_size{ 0 }; // Size of the file (in bytes)
|
||||
uint16_t reserved1{ 0 }; // Reserved, always 0
|
||||
uint16_t reserved2{ 0 }; // Reserved, always 0
|
||||
uint32_t offset_data{ 0 }; // Start position of pixel data (bytes from the beginning of the file)
|
||||
};
|
||||
|
||||
struct BMPInfoHeader {
|
||||
uint32_t size{ 0 }; // Size of this header (in bytes)
|
||||
int32_t width{ 0 }; // width of bitmap in pixels
|
||||
int32_t height{ 0 }; // height of bitmap in pixels
|
||||
// (if positive, bottom-up, with origin in lower left corner)
|
||||
// (if negative, top-down, with origin in upper left corner)
|
||||
uint16_t planes{ 1 }; // No. of planes for the target device, this is always 1
|
||||
uint16_t bit_count{ 0 }; // No. of bits per pixel
|
||||
uint32_t compression{ 0 }; // 0 or 3 - uncompressed. THIS PROGRAM CONSIDERS ONLY UNCOMPRESSED BMP images
|
||||
uint32_t size_image{ 0 }; // 0 - for uncompressed images
|
||||
int32_t x_pixels_per_meter{ 0 };
|
||||
int32_t y_pixels_per_meter{ 0 };
|
||||
uint32_t colors_used{ 0 }; // No. color indexes in the color table. Use 0 for the max number of colors allowed by bit_count
|
||||
uint32_t colors_important{ 0 }; // No. of colors used for displaying the bitmap. If 0 all colors are required
|
||||
};
|
||||
|
||||
struct BMPColorHeader {
|
||||
uint32_t red_mask{ 0x00ff0000 }; // Bit mask for the red channel
|
||||
uint32_t green_mask{ 0x0000ff00 }; // Bit mask for the green channel
|
||||
uint32_t blue_mask{ 0x000000ff }; // Bit mask for the blue channel
|
||||
uint32_t alpha_mask{ 0xff000000 }; // Bit mask for the alpha channel
|
||||
uint32_t color_space_type{ 0x73524742 }; // Default "sRGB" (0x73524742)
|
||||
uint32_t unused[16]{ 0 }; // Unused data for sRGB color space
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct BMP {
|
||||
BMPFileHeader file_header;
|
||||
BMPInfoHeader bmp_info_header;
|
||||
BMPColorHeader bmp_color_header;
|
||||
std::vector<uint8_t> data;
|
||||
|
||||
|
||||
BMP(const char *fname) {
|
||||
read(fname);
|
||||
}
|
||||
|
||||
int read(const char *fname) {
|
||||
std::ifstream inp{ fname, std::ios_base::binary };
|
||||
if (inp) {
|
||||
inp.read((char*)&file_header, sizeof(file_header));
|
||||
if(file_header.file_type != 0x4D42) {
|
||||
|
||||
return 50;//throw std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
inp.read((char*)&bmp_info_header, sizeof(bmp_info_header));
|
||||
|
||||
// The BMPColorHeader is used only for transparent images
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
// Check if the file has bit mask color information
|
||||
if(bmp_info_header.size >= (sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
||||
inp.read((char*)&bmp_color_header, sizeof(bmp_color_header));
|
||||
// Check if the pixel data is stored as BGRA and if the color space type is sRGB
|
||||
check_color_header(bmp_color_header);
|
||||
} else {
|
||||
//std::cerr << "Error! The file \"" << fname << "\" does not seem to contain bit mask information\n";
|
||||
return 51;//throw std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
}
|
||||
|
||||
// Jump to the pixel data location
|
||||
inp.seekg(file_header.offset_data, inp.beg);
|
||||
|
||||
// Adjust the header fields for output.
|
||||
// Some editors will put extra info in the image file, we only save the headers and the data.
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
} else {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
||||
}
|
||||
file_header.file_size = file_header.offset_data;
|
||||
|
||||
if (bmp_info_header.height < 0) {
|
||||
return 52;//throw std::runtime_error("The program can treat only BMP images with the origin in the bottom left corner!");
|
||||
}
|
||||
|
||||
data.resize(bmp_info_header.width * bmp_info_header.height * bmp_info_header.bit_count / 8);
|
||||
|
||||
// Here we check if we need to take into account row padding
|
||||
if (bmp_info_header.width % 4 == 0) {
|
||||
inp.read((char*)data.data(), data.size());
|
||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
||||
}
|
||||
else {
|
||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
||||
uint32_t new_stride = make_stride_aligned(4);
|
||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
||||
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
inp.read((char*)(data.data() + row_stride * y), row_stride);
|
||||
inp.read((char*)padding_row.data(), padding_row.size());
|
||||
}
|
||||
file_header.file_size += static_cast<uint32_t>(data.size()) + bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 53;//throw std::runtime_error("Unable to open the input image file "+std::string(fname));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_mem(std::vector<unsigned char> buffer) {
|
||||
std::stringstream inp;
|
||||
std::copy(buffer.begin(), buffer.end(),std::ostream_iterator<unsigned char>(inp,"\n"));
|
||||
if (inp) {
|
||||
inp.read((char*)&file_header, sizeof(file_header));
|
||||
if(file_header.file_type != 0x4D42) {
|
||||
|
||||
return 50;//throw std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
inp.read((char*)&bmp_info_header, sizeof(bmp_info_header));
|
||||
|
||||
// The BMPColorHeader is used only for transparent images
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
// Check if the file has bit mask color information
|
||||
if(bmp_info_header.size >= (sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
||||
inp.read((char*)&bmp_color_header, sizeof(bmp_color_header));
|
||||
// Check if the pixel data is stored as BGRA and if the color space type is sRGB
|
||||
check_color_header(bmp_color_header);
|
||||
} else {
|
||||
//std::cerr << "Error! The file \"" << fname << "\" does not seem to contain bit mask information\n";
|
||||
return 51;//throw std::runtime_error("Error! Unrecognized file format.");
|
||||
}
|
||||
}
|
||||
|
||||
// Jump to the pixel data location
|
||||
inp.seekg(file_header.offset_data, inp.beg);
|
||||
|
||||
// Adjust the header fields for output.
|
||||
// Some editors will put extra info in the image file, we only save the headers and the data.
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
} else {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
||||
}
|
||||
file_header.file_size = file_header.offset_data;
|
||||
|
||||
if (bmp_info_header.height < 0) {
|
||||
return 52;//throw std::runtime_error("The program can treat only BMP images with the origin in the bottom left corner!");
|
||||
}
|
||||
|
||||
data.resize(bmp_info_header.width * bmp_info_header.height * bmp_info_header.bit_count / 8);
|
||||
|
||||
// Here we check if we need to take into account row padding
|
||||
if (bmp_info_header.width % 4 == 0) {
|
||||
inp.read((char*)data.data(), data.size());
|
||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
||||
}
|
||||
else {
|
||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
||||
uint32_t new_stride = make_stride_aligned(4);
|
||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
||||
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
inp.read((char*)(data.data() + row_stride * y), row_stride);
|
||||
inp.read((char*)padding_row.data(), padding_row.size());
|
||||
}
|
||||
file_header.file_size += static_cast<uint32_t>(data.size()) + bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 53;//throw std::runtime_error("Unable to open the input image file "+std::string(fname));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BMP(int32_t width, int32_t height, bool has_alpha = true) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
width = 1;
|
||||
height = 1;
|
||||
}
|
||||
|
||||
bmp_info_header.width = width;
|
||||
bmp_info_header.height = height;
|
||||
if (has_alpha) {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
||||
|
||||
bmp_info_header.bit_count = 32;
|
||||
bmp_info_header.compression = 3;
|
||||
row_stride = width * 4;
|
||||
data.resize(row_stride * height);
|
||||
file_header.file_size = file_header.offset_data + data.size();
|
||||
}
|
||||
else {
|
||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
||||
|
||||
bmp_info_header.bit_count = 24;
|
||||
bmp_info_header.compression = 0;
|
||||
row_stride = width * 3;
|
||||
data.resize(row_stride * height);
|
||||
|
||||
uint32_t new_stride = make_stride_aligned(4);
|
||||
file_header.file_size = file_header.offset_data + static_cast<uint32_t>(data.size()) + bmp_info_header.height * (new_stride - row_stride);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned write(const char *fname) {
|
||||
std::ofstream of{ fname, std::ios_base::binary };
|
||||
if (of) {
|
||||
if (bmp_info_header.bit_count == 32) {
|
||||
write_headers_and_data(of);
|
||||
}
|
||||
else if (bmp_info_header.bit_count == 24) {
|
||||
if (bmp_info_header.width % 4 == 0) {
|
||||
write_headers_and_data(of);
|
||||
}
|
||||
else {
|
||||
uint32_t new_stride = make_stride_aligned(4);
|
||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
||||
|
||||
write_headers(of);
|
||||
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
of.write((const char*)(data.data() + row_stride * y), row_stride);
|
||||
of.write((const char*)padding_row.data(), padding_row.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 54;//throw std::runtime_error("The program can treat only 24 or 32 bits per pixel BMP files");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 55;//throw std::runtime_error("Unable to open the output image file.");
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DATA() {
|
||||
std::stringstream ss;
|
||||
if (ss) {
|
||||
if (bmp_info_header.bit_count == 32) {
|
||||
write_headers_and_datass(ss);
|
||||
}
|
||||
else if (bmp_info_header.bit_count == 24) {
|
||||
if (bmp_info_header.width % 4 == 0) {
|
||||
write_headers_and_datass(ss);
|
||||
}
|
||||
else {
|
||||
uint32_t new_stride = make_stride_aligned(4);
|
||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
||||
|
||||
write_headersss(ss);
|
||||
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
ss.write((const char*)(data.data() + row_stride * y), row_stride);
|
||||
ss.write((const char*)padding_row.data(), padding_row.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
std::string test11 = ss.str();
|
||||
std::vector<unsigned char> test12(test11.begin(), test11.end());
|
||||
return test12;
|
||||
|
||||
}
|
||||
|
||||
unsigned fill_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
||||
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
|
||||
return 59;
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fill_region_df(uint32_t x1, uint32_t y1, uint32_t w, uint32_t h, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
||||
|
||||
int x0 = x1;
|
||||
int y0 = this->bmp_info_header.height - y1 - h;
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
if ((x + w < (uint32_t)bmp_info_header.width) || this->bmp_info_header.height - y - h > 0) {
|
||||
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void manipulate_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h, uint8_t A) {
|
||||
int choice, choice2, intensity;
|
||||
cout << "What color do you want to change? " << endl;
|
||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
||||
cin >> choice;
|
||||
cout << "To what color do you want to change it too?" << endl;
|
||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
||||
cin >> choice2;
|
||||
cout << "Enter the intensity of the color. (From 0 to 255) " << endl;
|
||||
cin >> intensity;
|
||||
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
|
||||
return;//throw std::runtime_error("The region does not fit in the image!");
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
if (choice==1 && choice2==1)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make blue thing blue
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 0]>80 && data[channels * (y * bmp_info_header.width + x) + 0]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
//data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
||||
//data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
||||
//data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 1 && choice2==2)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make blue thing green
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 0]>80 && data[channels * (y * bmp_info_header.width + x) + 0]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 1 && choice2==3)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make blue thing red
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 0]>80 && data[channels * (y * bmp_info_header.width + x) + 0]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 2 && choice2==1)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make green thing blue
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 1]>80 && data[channels * (y * bmp_info_header.width + x) + 1]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 2 && choice2==2)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make green thing green
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 1]>80 && data[channels * (y * bmp_info_header.width + x) + 1]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 2 && choice2==3)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make green thing red
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 1]>80 && data[channels * (y * bmp_info_header.width + x) + 1]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 3 && choice2==1)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make red thing blue
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 2]>80 && data[channels * (y * bmp_info_header.width + x) + 2]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 3 && choice2==2)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make red thing green
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 2]>80 && data[channels * (y * bmp_info_header.width + x) + 2]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (choice == 3 && choice2==3)
|
||||
{
|
||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
||||
cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Make red thing blue
|
||||
if(data[channels * (y * bmp_info_header.width + x) + 2]>80 && data[channels * (y * bmp_info_header.width + x) + 2]<255)
|
||||
{
|
||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
||||
}
|
||||
if (channels == 4) {
|
||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int OrganizeAverageRed()
|
||||
{
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels=bmp_info_header.height*bmp_info_header.width;
|
||||
float intensity=0;
|
||||
float sum=0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
//cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Read red
|
||||
ColorBlue[y][x]=data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x]=data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x]=data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for(int y=0; y<bmp_info_header.height; y++)
|
||||
{
|
||||
for(int x=0; x<bmp_info_header.width; x++)
|
||||
{
|
||||
sum=ColorRed[y][x]+sum-((ColorBlue[y][x])/2+(ColorGreen[y][x])/2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity=sum/pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
int OrganizeAverageGreen()
|
||||
{
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels=bmp_info_header.height*bmp_info_header.width;
|
||||
float intensity=0;
|
||||
float sum=0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
//cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Read Green
|
||||
ColorBlue[y][x]=data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x]=data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x]=data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for(int y=0; y<bmp_info_header.height; y++)
|
||||
{
|
||||
for(int x=0; x<bmp_info_header.width; x++)
|
||||
{
|
||||
sum=ColorGreen[y][x]+sum-((ColorBlue[y][x])/2+(ColorRed[y][x])/2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity=sum/pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
int OrganizeAverageBlue()
|
||||
{
|
||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];;
|
||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
||||
float pixels=bmp_info_header.height*bmp_info_header.width;
|
||||
float intensity=0;
|
||||
float sum=0;
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
||||
//cout << channels*(y*bmp_info_header.width+x) << endl;
|
||||
//Read Blue
|
||||
ColorBlue[y][x]=data[channels * (y * bmp_info_header.width + x) + 0];
|
||||
ColorGreen[y][x]=data[channels * (y * bmp_info_header.width + x) + 1];
|
||||
ColorRed[y][x]=data[channels * (y * bmp_info_header.width + x) + 2];
|
||||
}
|
||||
}
|
||||
for(int y=0; y<bmp_info_header.height; y++)
|
||||
{
|
||||
for(int x=0; x<bmp_info_header.width; x++)
|
||||
{
|
||||
sum=ColorBlue[y][x]+sum-((ColorGreen[y][x])/2+(ColorRed[y][x])/2);
|
||||
}
|
||||
}
|
||||
|
||||
intensity=sum/pixels;
|
||||
cout << intensity << endl;
|
||||
return intensity;
|
||||
}
|
||||
|
||||
unsigned set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
||||
if (x0 >= (uint32_t)bmp_info_header.width || y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
||||
return 59;//throw std::runtime_error("The point is outside the image boundaries!");
|
||||
}
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
||||
if (channels == 4) {
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_pixel_df(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
||||
if (x0 >= (uint32_t)bmp_info_header.width || y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
||||
return;//throw std::runtime_error("The point is outside the image boundaries!");
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
||||
if (channels == 4) {
|
||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A, uint8_t line_w) {
|
||||
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
|
||||
return 59;//throw std::runtime_error("The rectangle does not fit in the image!");
|
||||
}
|
||||
|
||||
fill_region(x0, y0, w, line_w, B, G, R, A); // top line
|
||||
fill_region(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
||||
fill_region((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // right line
|
||||
fill_region(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // left line
|
||||
return 0;
|
||||
}
|
||||
|
||||
void draw_rectangle_df(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A, uint8_t line_w) {
|
||||
if (x0 + w > (uint32_t)bmp_info_header.width || y0 + h > (uint32_t)bmp_info_header.height) {
|
||||
return;//throw std::runtime_error("The rectangle does not fit in the image!");
|
||||
}
|
||||
|
||||
fill_region_df(x0, y0, w, line_w, B, G, R, A); // top line
|
||||
fill_region_df(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
||||
fill_region_df((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // right line
|
||||
fill_region_df(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R, A); // left line
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t row_stride{ 0 };
|
||||
|
||||
void write_headers(std::ofstream &of) {
|
||||
of.write((const char*)&file_header, sizeof(file_header));
|
||||
of.write((const char*)&bmp_info_header, sizeof(bmp_info_header));
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
of.write((const char*)&bmp_color_header, sizeof(bmp_color_header));
|
||||
}
|
||||
}
|
||||
|
||||
void write_headers_and_data(std::ofstream &of) {
|
||||
write_headers(of);
|
||||
of.write((const char*)data.data(), data.size());
|
||||
}
|
||||
|
||||
void write_headersss(std::stringstream &of) {
|
||||
of.write((const char*)&file_header, sizeof(file_header));
|
||||
of.write((const char*)&bmp_info_header, sizeof(bmp_info_header));
|
||||
if(bmp_info_header.bit_count == 32) {
|
||||
of.write((const char*)&bmp_color_header, sizeof(bmp_color_header));
|
||||
}
|
||||
}
|
||||
|
||||
void write_headers_and_datass(std::stringstream &of) {
|
||||
write_headersss(of);
|
||||
of.write((const char*)data.data(), data.size());
|
||||
}
|
||||
|
||||
// Add 1 to the row_stride until it is divisible with align_stride
|
||||
uint32_t make_stride_aligned(uint32_t align_stride) {
|
||||
uint32_t new_stride = row_stride;
|
||||
while (new_stride % align_stride != 0) {
|
||||
new_stride++;
|
||||
}
|
||||
return new_stride;
|
||||
}
|
||||
|
||||
// Check if the pixel data is stored as BGRA and if the color space type is sRGB
|
||||
void check_color_header(BMPColorHeader &bmp_color_header) {
|
||||
BMPColorHeader expected_color_header;
|
||||
if(expected_color_header.red_mask != bmp_color_header.red_mask ||
|
||||
expected_color_header.blue_mask != bmp_color_header.blue_mask ||
|
||||
expected_color_header.green_mask != bmp_color_header.green_mask ||
|
||||
expected_color_header.alpha_mask != bmp_color_header.alpha_mask) {
|
||||
return;//throw std::runtime_error("Unexpected color mask format! The program expects the pixel data to be in the BGRA format");
|
||||
}
|
||||
if(expected_color_header.color_space_type != bmp_color_header.color_space_type) {
|
||||
return;//throw std::runtime_error("Unexpected color space type! The program expects sRGB values");
|
||||
}
|
||||
}
|
||||
};
|
14
include/renderd7/bmpconverter.hpp
Normal file
14
include/renderd7/bmpconverter.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <renderd7/external/lodepng.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace BitmapConverter{
|
||||
//returns 0 if all went ok, non-0 if error
|
||||
//output image is always given in RGBA (with alpha channel), even if it's a BMP without alpha channel
|
||||
unsigned decodeBMP(std::vector<unsigned char>& image, unsigned& w, unsigned& h, const std::vector<unsigned char>& bmp);
|
||||
|
||||
std::vector<unsigned char> ConvertFile(std::string filename);
|
||||
|
||||
std::vector<unsigned char> ConvertData(std::vector<unsigned char> data);
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
#ifndef _3D_SHELL_FS_H
|
||||
#define _3D_SHELL_FS_H
|
||||
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
@ -26,5 +25,5 @@ Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new
|
||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf);
|
||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size);
|
||||
char *FS_GetFileTimestamp(const char *path);
|
||||
|
||||
#endif
|
||||
Result makeDirs(const char * path);
|
||||
Result openFile(Handle* fileHandle, const char * path, bool write);
|
250
include/renderd7/external/libnsbmp/libnsbmp.h
vendored
Normal file
250
include/renderd7/external/libnsbmp/libnsbmp.h
vendored
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright 2006 Richard Wilson <richard.wilson@netsurf-browser.org>
|
||||
* Copyright 2008 Sean Fox <dyntryx@gmail.com>
|
||||
*
|
||||
* This file is part of NetSurf's libnsbmp, http://www.netsurf-browser.org/
|
||||
* Licenced under the MIT License,
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Bitmap file decoding interface.
|
||||
*/
|
||||
|
||||
#ifndef libnsbmp_h_
|
||||
#define libnsbmp_h_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* bmp flags */
|
||||
#define BMP_NEW 0
|
||||
/** image is opaque (as opposed to having an alpha mask) */
|
||||
#define BMP_OPAQUE (1 << 0)
|
||||
/** memory should be wiped */
|
||||
#define BMP_CLEAR_MEMORY (1 << 1)
|
||||
|
||||
/**
|
||||
* error return values
|
||||
*/
|
||||
typedef enum {
|
||||
BMP_OK = 0,
|
||||
BMP_INSUFFICIENT_MEMORY = 1,
|
||||
BMP_INSUFFICIENT_DATA = 2,
|
||||
BMP_DATA_ERROR = 3
|
||||
} bmp_result;
|
||||
|
||||
/**
|
||||
* encoding types
|
||||
*/
|
||||
typedef enum {
|
||||
BMP_ENCODING_RGB = 0,
|
||||
BMP_ENCODING_RLE8 = 1,
|
||||
BMP_ENCODING_RLE4 = 2,
|
||||
BMP_ENCODING_BITFIELDS = 3
|
||||
} bmp_encoding;
|
||||
|
||||
/* API for Bitmap callbacks */
|
||||
typedef void* (*bmp_bitmap_cb_create)(int width, int height, unsigned int state);
|
||||
typedef void (*bmp_bitmap_cb_destroy)(void *bitmap);
|
||||
typedef unsigned char* (*bmp_bitmap_cb_get_buffer)(void *bitmap);
|
||||
typedef size_t (*bmp_bitmap_cb_get_bpp)(void *bitmap);
|
||||
|
||||
/**
|
||||
* The Bitmap callbacks function table
|
||||
*/
|
||||
typedef struct bmp_bitmap_callback_vt_s {
|
||||
/** Callback to allocate bitmap storage. */
|
||||
bmp_bitmap_cb_create bitmap_create;
|
||||
/** Called to free bitmap storage. */
|
||||
bmp_bitmap_cb_destroy bitmap_destroy;
|
||||
/** Return a pointer to the pixel data in a bitmap. */
|
||||
bmp_bitmap_cb_get_buffer bitmap_get_buffer;
|
||||
/** Find the width of a pixel row in bytes. */
|
||||
bmp_bitmap_cb_get_bpp bitmap_get_bpp;
|
||||
} bmp_bitmap_callback_vt;
|
||||
|
||||
/**
|
||||
* bitmap image
|
||||
*/
|
||||
typedef struct bmp_image {
|
||||
/** callbacks for bitmap functions */
|
||||
bmp_bitmap_callback_vt bitmap_callbacks;
|
||||
/** pointer to BMP data */
|
||||
uint8_t *bmp_data;
|
||||
/** width of BMP (valid after _analyse) */
|
||||
uint32_t width;
|
||||
/** heigth of BMP (valid after _analyse) */
|
||||
uint32_t height;
|
||||
/** whether the image has been decoded */
|
||||
bool decoded;
|
||||
/** decoded image */
|
||||
void *bitmap;
|
||||
|
||||
/* Internal members are listed below */
|
||||
/** total number of bytes of BMP data available */
|
||||
uint32_t buffer_size;
|
||||
/** pixel encoding type */
|
||||
bmp_encoding encoding;
|
||||
/** offset of bitmap data */
|
||||
uint32_t bitmap_offset;
|
||||
/** bits per pixel */
|
||||
uint16_t bpp;
|
||||
/** number of colours */
|
||||
uint32_t colours;
|
||||
/** colour table */
|
||||
uint32_t *colour_table;
|
||||
/** whether to use bmp's limited transparency */
|
||||
bool limited_trans;
|
||||
/** colour to display for "transparent" pixels when using limited
|
||||
* transparency
|
||||
*/
|
||||
uint32_t trans_colour;
|
||||
/** scanlines are top to bottom */
|
||||
bool reversed;
|
||||
/** image is part of an ICO, mask follows */
|
||||
bool ico;
|
||||
/** true if the bitmap does not contain an alpha channel */
|
||||
bool opaque;
|
||||
/** four bitwise mask */
|
||||
uint32_t mask[4];
|
||||
/** four bitwise shifts */
|
||||
int32_t shift[4];
|
||||
/** colour representing "transparency" in the bitmap */
|
||||
uint32_t transparent_index;
|
||||
} bmp_image;
|
||||
|
||||
typedef struct ico_image {
|
||||
bmp_image bmp;
|
||||
struct ico_image *next;
|
||||
} ico_image;
|
||||
|
||||
/**
|
||||
* icon image collection
|
||||
*/
|
||||
typedef struct ico_collection {
|
||||
/** callbacks for bitmap functions */
|
||||
bmp_bitmap_callback_vt bitmap_callbacks;
|
||||
/** width of largest BMP */
|
||||
uint16_t width;
|
||||
/** heigth of largest BMP */
|
||||
uint16_t height;
|
||||
|
||||
/* Internal members are listed below */
|
||||
/** pointer to ICO data */
|
||||
uint8_t *ico_data;
|
||||
/** total number of bytes of ICO data available */
|
||||
uint32_t buffer_size;
|
||||
/** root of linked list of images */
|
||||
ico_image *first;
|
||||
} ico_collection;
|
||||
|
||||
/**
|
||||
* Initialises bitmap ready for analysing the bitmap.
|
||||
*
|
||||
* \param bmp The Bitmap to initialise
|
||||
* \param callbacks The callbacks the library will call on operations.
|
||||
* \return BMP_OK on success or appropriate error code.
|
||||
*/
|
||||
bmp_result bmp_create(bmp_image *bmp, bmp_bitmap_callback_vt *callbacks);
|
||||
|
||||
/**
|
||||
* Initialises icon ready for analysing the icon
|
||||
*
|
||||
* \param bmp The Bitmap to initialise
|
||||
* \param callbacks The callbacks the library will call on operations.
|
||||
* \return BMP_OK on success or appropriate error code.
|
||||
*/
|
||||
bmp_result ico_collection_create(ico_collection *ico,
|
||||
bmp_bitmap_callback_vt *callbacks);
|
||||
|
||||
/**
|
||||
* Analyse a BMP prior to decoding.
|
||||
*
|
||||
* This will scan the data provided and perform checks to ensure the data is a
|
||||
* valid BMP and prepare the bitmap image structure ready for decode.
|
||||
*
|
||||
* This function must be called and resturn BMP_OK before bmp_decode() as it
|
||||
* prepares the bmp internal state for the decode process.
|
||||
*
|
||||
* \param bmp the BMP image to analyse.
|
||||
* \param size The size of data in cdata.
|
||||
* \param data The bitmap source data.
|
||||
* \return BMP_OK on success or error code on faliure.
|
||||
*/
|
||||
bmp_result bmp_analyse(bmp_image *bmp, size_t size, uint8_t *data);
|
||||
|
||||
/**
|
||||
* Analyse an ICO prior to decoding.
|
||||
*
|
||||
* This function will scan the data provided and perform checks to ensure the
|
||||
* data is a valid ICO.
|
||||
*
|
||||
* This function must be called before ico_find().
|
||||
*
|
||||
* \param ico the ICO image to analyse
|
||||
* \param size The size of data in cdata.
|
||||
* \param data The bitmap source data.
|
||||
* \return BMP_OK on success
|
||||
*/
|
||||
bmp_result ico_analyse(ico_collection *ico, size_t size, uint8_t *data);
|
||||
|
||||
/**
|
||||
* Decode a BMP
|
||||
*
|
||||
* This function decodes the BMP data such that bmp->bitmap is a valid
|
||||
* image. The state of bmp->decoded is set to TRUE on exit such that it
|
||||
* can easily be identified which BMPs are in a fully decoded state.
|
||||
*
|
||||
* \param bmp the BMP image to decode
|
||||
* \return BMP_OK on success
|
||||
*/
|
||||
bmp_result bmp_decode(bmp_image *bmp);
|
||||
|
||||
/**
|
||||
* Decode a BMP using "limited transparency"
|
||||
*
|
||||
* Bitmaps do not have native transparency support. However, there is a
|
||||
* "trick" that is used in some instances in which the first pixel of the
|
||||
* bitmap becomes the "transparency index". The decoding application can
|
||||
* replace this index with whatever background colour it chooses to
|
||||
* create the illusion of transparency.
|
||||
*
|
||||
* When to use transparency is at the discretion of the decoding
|
||||
* application.
|
||||
*
|
||||
* \param bmp the BMP image to decode
|
||||
* \param colour the colour to use as "transparent"
|
||||
* \return BMP_OK on success
|
||||
*/
|
||||
bmp_result bmp_decode_trans(bmp_image *bmp, uint32_t transparent_colour);
|
||||
|
||||
/**
|
||||
* Finds the closest BMP within an ICO collection
|
||||
*
|
||||
* This function finds the BMP with dimensions as close to a specified set
|
||||
* as possible from the images in the collection.
|
||||
*
|
||||
* \param ico the ICO collection to examine
|
||||
* \param width the preferred width (0 to use ICO header width)
|
||||
* \param height the preferred height (0 to use ICO header height)
|
||||
*/
|
||||
bmp_image *ico_find(ico_collection *ico, uint16_t width, uint16_t height);
|
||||
|
||||
/**
|
||||
* Finalise a BMP prior to destruction.
|
||||
*
|
||||
* \param bmp the BMP image to finalise.
|
||||
*/
|
||||
void bmp_finalise(bmp_image *bmp);
|
||||
|
||||
/**
|
||||
* Finalise an ICO prior to destruction.
|
||||
*
|
||||
* \param ico the ICO image to finalise,
|
||||
*/
|
||||
void ico_finalise(ico_collection *ico);
|
||||
|
||||
#endif
|
27
include/renderd7/external/libnsbmp/log.h
vendored
Normal file
27
include/renderd7/external/libnsbmp/log.h
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
* Licenced under the MIT License,
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _LIBNSBMP_LOG_H_
|
||||
#define _LIBNSBMP_LOG_H_
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define LOG(x) ((void) 0)
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
||||
# elif defined(__CC_NORCROFT)
|
||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
||||
# else
|
||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
7897
include/renderd7/external/stb_image.h
vendored
Normal file
7897
include/renderd7/external/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1724
include/renderd7/external/stb_image_write.h
vendored
Normal file
1724
include/renderd7/external/stb_image_write.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "json.hpp"
|
||||
#include <renderd7/external/json.hpp>
|
||||
|
||||
/// RenderD7::Lang
|
||||
namespace RenderD7::Lang
|
||||
@ -8,9 +8,9 @@ namespace RenderD7::Lang
|
||||
/// Get the 3ds System Language
|
||||
std::string getSys();
|
||||
/// Get a translated string
|
||||
/// key: The Key so the code can find your string
|
||||
/// \param key The Key so the code can find your string
|
||||
std::string get(const std::string &key);
|
||||
/// Load the lang file from dir structure en/app.json for sample
|
||||
/// lang: the folder name en, fr, de ... . I prefer geSys()
|
||||
/// \param lang the folder name en, fr, de ... . I prefer geSys()
|
||||
void load(const std::string &lang);
|
||||
} /// RenderD7::Lang
|
@ -25,6 +25,6 @@ class Log
|
||||
/// \param fmt_str the formatted style
|
||||
std::string format(const std::string& fmt_str, ...);
|
||||
private:
|
||||
/// param filename the name of the logfile
|
||||
/// \param filename the name of the logfile
|
||||
std::string filename;
|
||||
};
|
@ -16,18 +16,29 @@
|
||||
#include <sys/stat.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include "external/lodepng.h"
|
||||
#include "external/fs.h"
|
||||
#include <codecvt>
|
||||
#include "lang.hpp"
|
||||
#include "parameter.hpp"
|
||||
#include "thread.hpp"
|
||||
#include "ini.hpp"
|
||||
#include "stringtool.hpp"
|
||||
#include "Clock.hpp"
|
||||
#include <filesystem>
|
||||
#include <locale>
|
||||
#include <time.h>
|
||||
|
||||
#define RENDERD7VSTRING "0.6.2"
|
||||
#define CHANGELOG "0.6.2: \n0.6.10: rewrite Threadsystem, Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left Function.\nadd changelog\n0.6.01: add Threading system."
|
||||
#include <codecvt>
|
||||
|
||||
#include <renderd7/external/lodepng.h>
|
||||
#include <renderd7/lang.hpp>
|
||||
#include <renderd7/parameter.hpp>
|
||||
#include <renderd7/thread.hpp>
|
||||
#include <renderd7/ini.hpp>
|
||||
#include <renderd7/stringtool.hpp>
|
||||
#include <renderd7/Clock.hpp>
|
||||
#include <renderd7/bmp.hpp>
|
||||
#include <renderd7/bmpconverter.hpp>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <renderd7/external/fs.h>
|
||||
}
|
||||
|
||||
#define RENDERD7VSTRING "0.8.0"
|
||||
#define CHANGELOG "0.8.0: Implement BitmapPrinter\n0.7.3: Implement Over Render Overlay Framework\n0.7.2: Implement MT to csv file saving. Add RGB2HEX. \n0.7.1: Add the New Overlay Handler. Its Just in code and does nothing yet. \n0.7.0: Made Big Progress In the MT Ovl but it still crashes On a Scnd C3D_FrameEnd(). Implement 800px but doesn't work that good. \n0.6.2: Fix Crash when exiting trouth Home Menu. \n0.6.10: rewrite Threadsystem, Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left Function.\nadd changelog\n0.6.01: add Threading system."
|
||||
#define DEFAULT_CENTER 0.5f
|
||||
|
||||
extern C3D_RenderTarget* Top;
|
||||
@ -44,6 +55,7 @@ extern std::string dspststus;
|
||||
/// RenderD7
|
||||
namespace RenderD7
|
||||
{
|
||||
float GetDeltaTime();
|
||||
enum kbd{
|
||||
SWKBD,
|
||||
BKBD
|
||||
@ -53,6 +65,17 @@ namespace RenderD7
|
||||
NUMPAD,
|
||||
STANDARD
|
||||
};
|
||||
struct TObject
|
||||
{
|
||||
int x; //Position X
|
||||
int y; //Position Y
|
||||
int w; //Button Width
|
||||
int h; //Button Height
|
||||
std::string text = ""; //Text
|
||||
float correctx = 0; //Correct X Position
|
||||
float correcty = 0; //Correct Y Position
|
||||
float txtsize = 0.7f; //Set Text Size
|
||||
};
|
||||
/// Set current RenderScreen
|
||||
/// \param target The RenderTarget Top, Bottom
|
||||
void OnScreen(C3D_RenderTarget *target);
|
||||
@ -65,23 +88,27 @@ namespace RenderD7
|
||||
// Deconstruct sheet
|
||||
~Sheet();
|
||||
/// Load a Sritesheet
|
||||
/// path: Path to the Spritesheet (.t3x)
|
||||
/// \param path Path to the Spritesheet (.t3x)
|
||||
Result Load(const char *path);
|
||||
/// Unload the Spritesheet
|
||||
void Free();
|
||||
// The Spritesheet
|
||||
/// The Spritesheet
|
||||
C2D_SpriteSheet spritesheet;
|
||||
};
|
||||
/// Image Class
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
~Image();
|
||||
|
||||
void Unload();
|
||||
/// Load Image from Png
|
||||
/// path: path to png file
|
||||
/// \param path path to png file
|
||||
void LoadPng(const std::string path);
|
||||
/// Load the Image from buffer
|
||||
/// buffer: the frame buffer
|
||||
/// \param buffer the frame buffer
|
||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
||||
void LoadFromBitmap(BMP bitmap);
|
||||
/// Draw the Image directly
|
||||
/// \param x The x position
|
||||
/// \param y the y position
|
||||
@ -91,9 +118,11 @@ namespace RenderD7
|
||||
/// \brief Get The Image
|
||||
/// \return C2D_Image
|
||||
C2D_Image Get(){return this->img;}
|
||||
/// \img this is the C2D_Image
|
||||
|
||||
void FromSheet(RenderD7::Sheet sheet, size_t index);
|
||||
/// \param img this is the C2D_Image
|
||||
C2D_Image img;
|
||||
/// \loadet whether the image is loadet or not
|
||||
/// \param loadet whether the image is loadet or not
|
||||
bool loadet = false;
|
||||
};
|
||||
/// Sprite Class
|
||||
@ -102,8 +131,14 @@ namespace RenderD7
|
||||
public:
|
||||
/// \brief Construct Sprite
|
||||
Sprite();
|
||||
/// \brief Deconstruct Sprite
|
||||
~Sprite();
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||
/// \param index the number of the Sprite in the Sheet
|
||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param img the Image to load from.(RenderD7::Image)
|
||||
void FromImage(RenderD7::Image *img);
|
||||
bool Draw();
|
||||
void SetCenter(float x, float y);
|
||||
@ -127,7 +162,7 @@ namespace RenderD7
|
||||
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
||||
virtual void Draw() const = 0;
|
||||
//virtual void Ovl() const = 0;
|
||||
static void Load(std::unique_ptr<Scene> scene);
|
||||
static void Load(std::unique_ptr<Scene> scene, bool fade = false);
|
||||
static void Back();
|
||||
static void doDraw();
|
||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
||||
@ -137,7 +172,33 @@ namespace RenderD7
|
||||
class RSettings : public RenderD7::Scene
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
enum RState {
|
||||
RSETTINGS,
|
||||
RINFO
|
||||
};
|
||||
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
||||
|
||||
std::string rd7srstate = "false";
|
||||
std::string csvstate = "false";
|
||||
std::string mtovlstate = "false";
|
||||
std::string fpsstate = "60";
|
||||
std::string mtscreenstate = "Top";
|
||||
std::string mttxtcolstate = "#ffffff";
|
||||
std::string mtcola = "255";
|
||||
std::string mttxtcola = "255";
|
||||
|
||||
|
||||
std::vector<RenderD7::TObject> buttons =
|
||||
{
|
||||
{20, 35, 120, 35, "RD7SR", -11, 10},
|
||||
{20, 85, 120, 35, "MT_CSV", -15, 9},
|
||||
{20, 135, 120, 35, "MT_OVL", -19, 10},
|
||||
{20, 185, 120, 35, "FPS", 6, 10},
|
||||
{180, 35, 120, 35, "MTSCREEN", -29, 10},
|
||||
{180, 85, 120, 35, "DSPERR", -13, 10},
|
||||
{180, 135, 120, 35, "INFO", 2, 10},
|
||||
{180, 185, 120, 35, "", -13, 10}
|
||||
};
|
||||
public:
|
||||
RSettings();
|
||||
void Draw(void) const override;
|
||||
@ -147,12 +208,41 @@ namespace RenderD7
|
||||
|
||||
void LoadSettings();
|
||||
|
||||
/*class Ovl {
|
||||
class Ovl {
|
||||
public:
|
||||
virtual ~Ovl(){}
|
||||
virtual void Draw() const = 0;
|
||||
virtual void Logic() = 0;
|
||||
inline bool IsKilled() {return this->iskilled; }
|
||||
inline void Kill() { iskilled = true; }
|
||||
private:
|
||||
bool iskilled = false;
|
||||
};
|
||||
void AddOvl(RenderD7::Ovl overlay);*/
|
||||
|
||||
class DSP_NF : public RenderD7::Ovl
|
||||
{
|
||||
public:
|
||||
DSP_NF();
|
||||
void Draw(void) const override;
|
||||
void Logic() override;
|
||||
private:
|
||||
int msgposy = 240;
|
||||
int delay = 0;
|
||||
};
|
||||
|
||||
class Toast : public RenderD7::Ovl
|
||||
{
|
||||
public:
|
||||
Toast(std::string head, std::string msg);
|
||||
void Draw(void) const override;
|
||||
void Logic() override;
|
||||
private:
|
||||
std::string head, msg;
|
||||
int msgposy = 240;
|
||||
int delay = 0;
|
||||
};
|
||||
|
||||
void AddOvl(std::unique_ptr<RenderD7::Ovl> scene);
|
||||
namespace Color
|
||||
{
|
||||
struct rgba
|
||||
@ -166,6 +256,7 @@ namespace RenderD7
|
||||
|
||||
u8 m_r, m_g ,m_b, m_a;
|
||||
};
|
||||
std::string RGB2Hex(int r, int g, int b);
|
||||
u32 Hex(const std::string color, u8 a = 255);
|
||||
}
|
||||
int GetRandomInt(int b, int e);
|
||||
@ -173,18 +264,21 @@ namespace RenderD7
|
||||
bool DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX = 1.0, float scaleY = 1.0);
|
||||
namespace Error
|
||||
{
|
||||
void DisplayError(std::string toptext, std::string errortext, int timesec);
|
||||
void DisplayError(std::string toptext, std::string errortext, int timesec = 3);
|
||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
||||
}
|
||||
namespace Init
|
||||
{
|
||||
Result Main(std::string app_name = "RD7Game");
|
||||
Result Reload();
|
||||
void Graphics();
|
||||
void NdspFirm(bool useit = false);
|
||||
}
|
||||
namespace Exit
|
||||
{
|
||||
void Main();
|
||||
void NdspFirm();
|
||||
void Graphics();
|
||||
}
|
||||
namespace Msg
|
||||
{
|
||||
@ -198,10 +292,19 @@ namespace RenderD7
|
||||
inline int StringtoInt(std::string inp){return std::atoi(inp.c_str());}
|
||||
inline bool FloatToBool(float inp){if(inp == 1)return true; else return false;}
|
||||
}
|
||||
|
||||
struct DirContent
|
||||
{
|
||||
std::string name;
|
||||
std::string path;
|
||||
bool isDir;
|
||||
};
|
||||
|
||||
namespace FS
|
||||
{
|
||||
bool FileExist(const std::string& path);
|
||||
}
|
||||
|
||||
bool IsNdspInit();
|
||||
void SetupLog(void);
|
||||
std::string GetFramerate();
|
||||
@ -210,6 +313,7 @@ namespace RenderD7
|
||||
|
||||
void ClearTextBufs(void);
|
||||
|
||||
std::string Kbd(int lenght, SwkbdType tp);
|
||||
bool DrawRect(float x, float y, float w, float h, u32 color);
|
||||
bool DrawNFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
||||
bool DrawPx(float x, float y, u32 color);
|
||||
@ -224,6 +328,8 @@ namespace RenderD7
|
||||
bool DrawCircle(float x, float y, float radius, u32 color);
|
||||
bool DrawImage(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f);
|
||||
void FrameEnd();
|
||||
void ToggleRD7SR();
|
||||
bool IsRD7SR();
|
||||
|
||||
class SpriteSheetAnimation : public RenderD7::Sprite
|
||||
{
|
||||
@ -239,17 +345,7 @@ namespace RenderD7
|
||||
RenderD7::Sheet *sheet;
|
||||
float time;
|
||||
};
|
||||
struct TObject
|
||||
{
|
||||
int x; //Position X
|
||||
int y; //Position Y
|
||||
int w; //Button Width
|
||||
int h; //Button Height
|
||||
std::string text = ""; //Text
|
||||
float correctx = 0; //Correct X Position
|
||||
float correcty = 0; //Correct Y Position
|
||||
float txtsize = 0.7f; //Set Text Size
|
||||
};
|
||||
|
||||
|
||||
struct TLBtn
|
||||
{
|
||||
@ -281,13 +377,9 @@ namespace RenderD7
|
||||
void DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor);
|
||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
||||
bool touchTLBtn(touchPosition touch, RenderD7::TLBtn button);
|
||||
void DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
||||
struct DirContent
|
||||
{
|
||||
std::string name;
|
||||
std::string path;
|
||||
bool isDir;
|
||||
};
|
||||
|
||||
struct Checkbox
|
||||
{
|
||||
float x, y, s;
|
||||
@ -295,11 +387,13 @@ namespace RenderD7
|
||||
u32 outcol, incol, chcol;
|
||||
};
|
||||
void DrawCheckbox(Checkbox box);
|
||||
/*class Console
|
||||
std::string FormatString(std::string fmt_str, ...);
|
||||
std::string GetTimeStr(void);
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
Console();
|
||||
Console(int x, int y, int w, int h, int a = 255);
|
||||
Console(int x, int y, int w, int h, u8 a = 255);
|
||||
Console(int x, int y, int w, int h, RenderD7::Color::rgba col);
|
||||
Console(int x, int y, int w, int h, std::string name, RenderD7::Color::rgba col = {255, 255, 255, 255}, RenderD7::Color::rgba barcol = {0, 0, 0, 255}, RenderD7::Color::rgba outlinecol = {222, 222, 222, 255});
|
||||
void On(C3D_RenderTarget *t_cscreen);
|
||||
@ -315,10 +409,40 @@ namespace RenderD7
|
||||
RenderD7::Color::rgba color = {255, 255, 255, 255};
|
||||
RenderD7::Color::rgba outlinecol = {222, 222, 222, 255};
|
||||
RenderD7::Color::rgba barcolor = {0, 0, 0, 255};
|
||||
};*/
|
||||
};
|
||||
|
||||
bool NameIsEndingWith(const std::string &name, const std::vector<std::string> &extensions);
|
||||
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions);
|
||||
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
|
||||
|
||||
class BitmapPrinter
|
||||
{
|
||||
public:
|
||||
BitmapPrinter(int w, int h);
|
||||
~BitmapPrinter();
|
||||
bool DecodeFile(std::string file);
|
||||
|
||||
bool DecodeMem(std::vector<unsigned char> buffer);
|
||||
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
|
||||
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
|
||||
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
|
||||
void UsePreMap(BMP map);
|
||||
void UsePrePrintMap(BitmapPrinter printmap);
|
||||
BMP GetBitmap(){ return bitmap; }
|
||||
void SaveBmp(std::string name);
|
||||
void SavePng(std::string name);
|
||||
|
||||
void CreateScreen(C3D_RenderTarget *target);
|
||||
void DrawScreen(int framerate);
|
||||
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
|
||||
void ClearBlank();
|
||||
RenderD7::Image GetImage();
|
||||
private:
|
||||
int frame = 0;
|
||||
RenderD7::Image renderframe;
|
||||
bool isscreen = false;
|
||||
C3D_RenderTarget* targetr;
|
||||
BMP bitmap = NULL;
|
||||
BMP blank = NULL;
|
||||
};
|
||||
} /// RenderD7
|
@ -19,6 +19,7 @@ public:
|
||||
void stop();
|
||||
|
||||
private:
|
||||
/// \param dataSize the Size of the filedata
|
||||
u32 dataSize;
|
||||
ndspWaveBuf waveBuf;
|
||||
u8* data = NULL;
|
@ -3,7 +3,7 @@
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include "parameter.hpp"
|
||||
#include <renderd7/parameter.hpp>
|
||||
|
||||
using CTRU_Thread = Thread;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Clock.hpp"
|
||||
#include <renderd7/Clock.hpp>
|
||||
|
||||
namespace rnd7{
|
||||
enum class TweenType : int {Position = 1, Color, Alpha};
|
@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <codecvt>
|
||||
#include <map>
|
||||
#include "lang.hpp"
|
||||
#include "parameter.hpp"
|
||||
#include "thread.hpp"
|
||||
#include "ini.hpp"
|
||||
#include "stringtool.hpp"
|
||||
|
||||
enum EngineType
|
||||
{
|
||||
_2D,
|
||||
_3D
|
||||
};
|
||||
|
||||
namespace Npi
|
||||
class Game {
|
||||
public:
|
||||
Game(EngineType, std::string name);
|
||||
~Game(){}
|
||||
private:
|
||||
std::string g_name;
|
||||
EngineType g_etype;
|
||||
};
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "Clock.hpp"
|
||||
#include <renderd7/Clock.hpp>
|
||||
|
||||
namespace rnd7 {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "Time.hpp"
|
||||
#include <renderd7/Time.hpp>
|
||||
|
||||
|
||||
namespace rnd7 {
|
106
source/bmpconverter.cpp
Normal file
106
source/bmpconverter.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include <renderd7/bmpconverter.hpp>
|
||||
|
||||
namespace BitmapConverter{
|
||||
|
||||
//returns 0 if all went ok, non-0 if error
|
||||
//output image is always given in RGBA (with alpha channel), even if it's a BMP without alpha channel
|
||||
unsigned decodeBMP(std::vector<unsigned char>& image, unsigned& w, unsigned& h, const std::vector<unsigned char>& bmp) {
|
||||
static const unsigned MINHEADER = 54; //minimum BMP header size
|
||||
|
||||
if(bmp.size() < MINHEADER) return -1;
|
||||
if(bmp[0] != 'B' || bmp[1] != 'M') return 1; //It's not a BMP file if it doesn't start with marker 'BM'
|
||||
unsigned pixeloffset = bmp[10] + 256 * bmp[11]; //where the pixel data starts
|
||||
//read width and height from BMP header
|
||||
w = bmp[18] + bmp[19] * 256;
|
||||
h = bmp[22] + bmp[23] * 256;
|
||||
//read number of channels from BMP header
|
||||
if(bmp[28] != 24 && bmp[28] != 32) return 2; //only 24-bit and 32-bit BMPs are supported.
|
||||
unsigned numChannels = bmp[28] / 8;
|
||||
|
||||
//The amount of scanline bytes is width of image times channels, with extra bytes added if needed
|
||||
//to make it a multiple of 4 bytes.
|
||||
unsigned scanlineBytes = w * numChannels;
|
||||
if(scanlineBytes % 4 != 0) scanlineBytes = (scanlineBytes / 4) * 4 + 4;
|
||||
|
||||
unsigned dataSize = scanlineBytes * h;
|
||||
if(bmp.size() < dataSize + pixeloffset) return 3; //BMP file too small to contain all pixels
|
||||
|
||||
image.resize(w * h * 4);
|
||||
|
||||
/*
|
||||
There are 3 differences between BMP and the raw image buffer for LodePNG:
|
||||
-it's upside down
|
||||
-it's in BGR instead of RGB format (or BRGA instead of RGBA)
|
||||
-each scanline has padding bytes to make it a multiple of 4 if needed
|
||||
The 2D for loop below does all these 3 conversions at once.
|
||||
*/
|
||||
for(unsigned y = 0; y < h; y++)
|
||||
for(unsigned x = 0; x < w; x++) {
|
||||
//pixel start byte position in the BMP
|
||||
unsigned bmpos = pixeloffset + (h - y - 1) * scanlineBytes + numChannels * x;
|
||||
//pixel start byte position in the new raw image
|
||||
unsigned newpos = 4 * y * w + 4 * x;
|
||||
if(numChannels == 3) {
|
||||
image[newpos + 0] = bmp[bmpos + 2]; //R
|
||||
image[newpos + 1] = bmp[bmpos + 1]; //G
|
||||
image[newpos + 2] = bmp[bmpos + 0]; //B
|
||||
image[newpos + 3] = 255; //A
|
||||
} else {
|
||||
image[newpos + 0] = bmp[bmpos + 2]; //R
|
||||
image[newpos + 1] = bmp[bmpos + 1]; //G
|
||||
image[newpos + 2] = bmp[bmpos + 0]; //B
|
||||
image[newpos + 3] = bmp[bmpos + 3]; //A
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> ConvertFile(std::string filename) {
|
||||
|
||||
std::vector<unsigned char> bmp;
|
||||
lodepng::load_file(bmp, filename);
|
||||
|
||||
std::vector<unsigned char> image;
|
||||
unsigned w, h;
|
||||
unsigned error = BitmapConverter::decodeBMP(image, w, h, bmp);
|
||||
|
||||
if(error) {
|
||||
std::cout << "BMP decoding error " << error << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::vector<unsigned char> png;
|
||||
error = lodepng::encode(png, image, w, h);
|
||||
|
||||
if(error) {
|
||||
std::cout << "PNG encoding error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||
|
||||
}
|
||||
|
||||
return png;
|
||||
|
||||
}
|
||||
|
||||
std::vector<unsigned char> ConvertData(std::vector<unsigned char> data) {
|
||||
|
||||
std::vector<unsigned char> image;
|
||||
unsigned w, h;
|
||||
unsigned error = BitmapConverter::decodeBMP(image, w, h, data);
|
||||
|
||||
if(error) {
|
||||
std::cout << "BMP decoding error " << error << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::vector<unsigned char> png;
|
||||
error = lodepng::encode(png, image, w, h);
|
||||
|
||||
if(error) {
|
||||
std::cout << "PNG encoding error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||
|
||||
}
|
||||
|
||||
return png;
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "lang.hpp"
|
||||
#include <renderd7/lang.hpp>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
@ -1,4 +1,4 @@
|
||||
#include "log.hpp"
|
||||
#include <renderd7/log.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -19,7 +19,7 @@ std::string Log::logDate(void)
|
||||
struct tm timeStruct;
|
||||
time(&unixTime);
|
||||
localtime_r(&unixTime, &timeStruct);
|
||||
return format("%04i-%02i-%02i %02i:%02i:%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday,
|
||||
return format("%04i-%02i-%02i_%02i-%02i-%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday,
|
||||
timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ Log::Log()
|
||||
|
||||
void Log::Init(const char *filename)
|
||||
{
|
||||
std::string name = "logs/Log_" + Log::logDate() + filename + ".txt";
|
||||
std::string name = "sdmc:/" + Log::logDate() + filename + ".txt";
|
||||
this->filename = name.c_str();
|
||||
if ((access(name.c_str(), F_OK) == 0))
|
||||
{
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#include "sound.hpp"
|
||||
#include <renderd7/sound.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
@ -1,4 +1,4 @@
|
||||
#include "thread.hpp"
|
||||
#include <renderd7/thread.hpp>
|
||||
namespace RenderD7 {
|
||||
void Threads::Exit()
|
||||
{
|
Reference in New Issue
Block a user