@ -0,0 +1,2 @@ |
||||
#Fri Jul 17 18:05:12 CDT 2020 |
||||
gradle.version=6.4.1 |
@ -0,0 +1,22 @@ |
||||
# Getting Started |
||||
|
||||
### Reference Documentation |
||||
For further reference, please consider the following sections: |
||||
|
||||
* [Official Gradle documentation](https://docs.gradle.org) |
||||
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/gradle-plugin/reference/html/) |
||||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/gradle-plugin/reference/html/#build-image) |
||||
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications) |
||||
|
||||
### Guides |
||||
The following guides illustrate how to use some features concretely: |
||||
|
||||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) |
||||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) |
||||
* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/) |
||||
|
||||
### Additional Links |
||||
These additional references should also help you: |
||||
|
||||
* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) |
||||
|
@ -0,0 +1,24 @@ |
||||
plugins { |
||||
id 'org.springframework.boot' version '2.3.1.RELEASE' |
||||
id 'io.spring.dependency-management' version '1.0.9.RELEASE' |
||||
id 'java' |
||||
} |
||||
|
||||
group = 'com.example' |
||||
version = '0.0.1-SNAPSHOT' |
||||
sourceCompatibility = '1.8' |
||||
|
||||
repositories { |
||||
mavenCentral() |
||||
} |
||||
|
||||
dependencies { |
||||
implementation 'org.springframework.boot:spring-boot-starter-web' |
||||
testImplementation('org.springframework.boot:spring-boot-starter-test') { |
||||
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' |
||||
} |
||||
} |
||||
|
||||
test { |
||||
useJUnitPlatform() |
||||
} |
@ -0,0 +1 @@ |
||||
server.port=4503 |
@ -0,0 +1,5 @@ |
||||
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip |
||||
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
@ -0,0 +1,185 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
# |
||||
# Copyright 2015 the original author or authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# https://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
|
||||
############################################################################## |
||||
## |
||||
## Gradle start up script for UN*X |
||||
## |
||||
############################################################################## |
||||
|
||||
# Attempt to set APP_HOME |
||||
# Resolve links: $0 may be a link |
||||
PRG="$0" |
||||
# Need this for relative symlinks. |
||||
while [ -h "$PRG" ] ; do |
||||
ls=`ls -ld "$PRG"` |
||||
link=`expr "$ls" : '.*-> \(.*\)$'` |
||||
if expr "$link" : '/.*' > /dev/null; then |
||||
PRG="$link" |
||||
else |
||||
PRG=`dirname "$PRG"`"/$link" |
||||
fi |
||||
done |
||||
SAVED="`pwd`" |
||||
cd "`dirname \"$PRG\"`/" >/dev/null |
||||
APP_HOME="`pwd -P`" |
||||
cd "$SAVED" >/dev/null |
||||
|
||||
APP_NAME="Gradle" |
||||
APP_BASE_NAME=`basename "$0"` |
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' |
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value. |
||||
MAX_FD="maximum" |
||||
|
||||
warn () { |
||||
echo "$*" |
||||
} |
||||
|
||||
die () { |
||||
echo |
||||
echo "$*" |
||||
echo |
||||
exit 1 |
||||
} |
||||
|
||||
# OS specific support (must be 'true' or 'false'). |
||||
cygwin=false |
||||
msys=false |
||||
darwin=false |
||||
nonstop=false |
||||
case "`uname`" in |
||||
CYGWIN* ) |
||||
cygwin=true |
||||
;; |
||||
Darwin* ) |
||||
darwin=true |
||||
;; |
||||
MINGW* ) |
||||
msys=true |
||||
;; |
||||
NONSTOP* ) |
||||
nonstop=true |
||||
;; |
||||
esac |
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar |
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM. |
||||
if [ -n "$JAVA_HOME" ] ; then |
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
||||
# IBM's JDK on AIX uses strange locations for the executables |
||||
JAVACMD="$JAVA_HOME/jre/sh/java" |
||||
else |
||||
JAVACMD="$JAVA_HOME/bin/java" |
||||
fi |
||||
if [ ! -x "$JAVACMD" ] ; then |
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
else |
||||
JAVACMD="java" |
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
|
||||
# Increase the maximum file descriptors if we can. |
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then |
||||
MAX_FD_LIMIT=`ulimit -H -n` |
||||
if [ $? -eq 0 ] ; then |
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then |
||||
MAX_FD="$MAX_FD_LIMIT" |
||||
fi |
||||
ulimit -n $MAX_FD |
||||
if [ $? -ne 0 ] ; then |
||||
warn "Could not set maximum file descriptor limit: $MAX_FD" |
||||
fi |
||||
else |
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" |
||||
fi |
||||
fi |
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock |
||||
if $darwin; then |
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" |
||||
fi |
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java |
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then |
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` |
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` |
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"` |
||||
|
||||
# We build the pattern for arguments to be converted via cygpath |
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` |
||||
SEP="" |
||||
for dir in $ROOTDIRSRAW ; do |
||||
ROOTDIRS="$ROOTDIRS$SEP$dir" |
||||
SEP="|" |
||||
done |
||||
OURCYGPATTERN="(^($ROOTDIRS))" |
||||
# Add a user-defined pattern to the cygpath arguments |
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then |
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" |
||||
fi |
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh |
||||
i=0 |
||||
for arg in "$@" ; do |
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` |
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option |
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition |
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` |
||||
else |
||||
eval `echo args$i`="\"$arg\"" |
||||
fi |
||||
i=`expr $i + 1` |
||||
done |
||||
case $i in |
||||
0) set -- ;; |
||||
1) set -- "$args0" ;; |
||||
2) set -- "$args0" "$args1" ;; |
||||
3) set -- "$args0" "$args1" "$args2" ;; |
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;; |
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; |
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; |
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; |
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; |
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; |
||||
esac |
||||
fi |
||||
|
||||
# Escape application args |
||||
save () { |
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done |
||||
echo " " |
||||
} |
||||
APP_ARGS=`save "$@"` |
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules |
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" |
||||
|
||||
exec "$JAVACMD" "$@" |
@ -0,0 +1,104 @@ |
||||
@rem |
||||
@rem Copyright 2015 the original author or authors. |
||||
@rem |
||||
@rem Licensed under the Apache License, Version 2.0 (the "License"); |
||||
@rem you may not use this file except in compliance with the License. |
||||
@rem You may obtain a copy of the License at |
||||
@rem |
||||
@rem https://www.apache.org/licenses/LICENSE-2.0 |
||||
@rem |
||||
@rem Unless required by applicable law or agreed to in writing, software |
||||
@rem distributed under the License is distributed on an "AS IS" BASIS, |
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
@rem See the License for the specific language governing permissions and |
||||
@rem limitations under the License. |
||||
@rem |
||||
|
||||
@if "%DEBUG%" == "" @echo off |
||||
@rem ########################################################################## |
||||
@rem |
||||
@rem Gradle startup script for Windows |
||||
@rem |
||||
@rem ########################################################################## |
||||
|
||||
@rem Set local scope for the variables with windows NT shell |
||||
if "%OS%"=="Windows_NT" setlocal |
||||
|
||||
set DIRNAME=%~dp0 |
||||
if "%DIRNAME%" == "" set DIRNAME=. |
||||
set APP_BASE_NAME=%~n0 |
||||
set APP_HOME=%DIRNAME% |
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. |
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi |
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" |
||||
|
||||
@rem Find java.exe |
||||
if defined JAVA_HOME goto findJavaFromJavaHome |
||||
|
||||
set JAVA_EXE=java.exe |
||||
%JAVA_EXE% -version >NUL 2>&1 |
||||
if "%ERRORLEVEL%" == "0" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:findJavaFromJavaHome |
||||
set JAVA_HOME=%JAVA_HOME:"=% |
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe |
||||
|
||||
if exist "%JAVA_EXE%" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:init |
||||
@rem Get command-line arguments, handling Windows variants |
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args |
||||
|
||||
:win9xME_args |
||||
@rem Slurp the command line arguments. |
||||
set CMD_LINE_ARGS= |
||||
set _SKIP=2 |
||||
|
||||
:win9xME_args_slurp |
||||
if "x%~1" == "x" goto execute |
||||
|
||||
set CMD_LINE_ARGS=%* |
||||
|
||||
:execute |
||||
@rem Setup the command line |
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar |
||||
|
||||
|
||||
@rem Execute Gradle |
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% |
||||
|
||||
:end |
||||
@rem End local scope for the variables with windows NT shell |
||||
if "%ERRORLEVEL%"=="0" goto mainEnd |
||||
|
||||
:fail |
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of |
||||
rem the _cmd.exe /c_ return code! |
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 |
||||
exit /b 1 |
||||
|
||||
:mainEnd |
||||
if "%OS%"=="Windows_NT" endlocal |
||||
|
||||
:omega |
@ -0,0 +1 @@ |
||||
rootProject.name = 'demo' |
@ -0,0 +1,19 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import java.util.HashMap; |
||||
|
||||
@RestController |
||||
public class Controller { |
||||
|
||||
@GetMapping("/image") |
||||
public HashMap<String,String> helloWorld(@RequestParam("url") String url){ |
||||
HashMap<String,String> map = new HashMap<>(); |
||||
map.put("test1",Integer.toString(1)); |
||||
map.put("test2","Hello World"); |
||||
return map; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
public class Controller { |
||||
|
||||
@GetMapping("/") |
||||
public String helloWorld() { |
||||
return "Hello from Spring!"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
@SpringBootApplication |
||||
public class DemoApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(DemoApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1 @@ |
||||
server.port=4503 |
@ -0,0 +1,13 @@ |
||||
package com.example.demo; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
||||
@SpringBootTest |
||||
class DemoApplicationTests { |
||||
|
||||
@Test |
||||
void contextLoads() { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,21 @@ |
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert. |
||||
|
||||
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. |
@ -0,0 +1,86 @@ |
||||
# arr-flatten [![NPM version](https://img.shields.io/npm/v/arr-flatten.svg?style=flat)](https://www.npmjs.com/package/arr-flatten) [![NPM monthly downloads](https://img.shields.io/npm/dm/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![NPM total downloads](https://img.shields.io/npm/dt/arr-flatten.svg?style=flat)](https://npmjs.org/package/arr-flatten) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/arr-flatten.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/arr-flatten) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/arr-flatten.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/arr-flatten) |
||||
|
||||
> Recursively flatten an array or arrays. |
||||
|
||||
## Install |
||||
|
||||
Install with [npm](https://www.npmjs.com/): |
||||
|
||||
```sh |
||||
$ npm install --save arr-flatten |
||||
``` |
||||
|
||||
## Install |
||||
|
||||
Install with [bower](https://bower.io/) |
||||
|
||||
```sh |
||||
$ bower install arr-flatten --save |
||||
``` |
||||
|
||||
## Usage |
||||
|
||||
```js |
||||
var flatten = require('arr-flatten'); |
||||
|
||||
flatten(['a', ['b', ['c']], 'd', ['e']]); |
||||
//=> ['a', 'b', 'c', 'd', 'e'] |
||||
``` |
||||
|
||||
## Why another flatten utility? |
||||
|
||||
I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%. |
||||
|
||||
## About |
||||
|
||||
### Related projects |
||||
|
||||
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.") |
||||
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.") |
||||
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.") |
||||
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.") |
||||
|
||||
### Contributing |
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). |
||||
|
||||
### Contributors |
||||
|
||||
| **Commits** | **Contributor** | |
||||
| --- | --- | |
||||
| 20 | [jonschlinkert](https://github.com/jonschlinkert) | |
||||
| 1 | [lukeed](https://github.com/lukeed) | |
||||
|
||||
### Building docs |
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ |
||||
|
||||
To generate the readme, run the following command: |
||||
|
||||
```sh |
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb |
||||
``` |
||||
|
||||
### Running tests |
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: |
||||
|
||||
```sh |
||||
$ npm install && npm test |
||||
``` |
||||
|
||||
### Author |
||||
|
||||
**Jon Schlinkert** |
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert) |
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) |
||||
|
||||
### License |
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). |
||||
Released under the [MIT License](LICENSE). |
||||
|
||||
*** |
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._ |
@ -0,0 +1,22 @@ |
||||
/*! |
||||
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
||||
* |
||||
* Copyright (c) 2014-2017, Jon Schlinkert. |
||||
* Released under the MIT License. |
||||
*/ |
||||
|
||||
'use strict'; |
||||
|
||||
module.exports = function (arr) { |
||||
return flat(arr, []); |
||||
}; |
||||
|
||||
function flat(arr, res) { |
||||
var i = 0, cur; |
||||
var len = arr.length; |
||||
for (; i < len; i++) { |
||||
cur = arr[i]; |
||||
Array.isArray(cur) ? flat(cur, res) : res.push(cur); |
||||
} |
||||
return res; |
||||
} |
@ -0,0 +1,115 @@ |
||||
{ |
||||
"_from": "arr-flatten@^1.1.0", |
||||
"_id": "arr-flatten@1.1.0", |
||||
"_inBundle": false, |
||||
"_integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", |
||||
"_location": "/arr-flatten", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "range", |
||||
"registry": true, |
||||
"raw": "arr-flatten@^1.1.0", |
||||
"name": "arr-flatten", |
||||
"escapedName": "arr-flatten", |
||||
"rawSpec": "^1.1.0", |
||||
"saveSpec": null, |
||||
"fetchSpec": "^1.1.0" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/image-pixels", |
||||
"/pxls", |
||||
"/to-uint8" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", |
||||
"_shasum": "36048bbff4e7b47e136644316c99669ea5ae91f1", |
||||
"_spec": "arr-flatten@^1.1.0", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-pixels", |
||||
"author": { |
||||
"name": "Jon Schlinkert", |
||||
"url": "https://github.com/jonschlinkert" |
||||
}, |
||||
"bugs": { |
||||
"url": "https://github.com/jonschlinkert/arr-flatten/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"contributors": [ |
||||
{ |
||||
"name": "Jon Schlinkert", |
||||
"url": "http://twitter.com/jonschlinkert" |
||||
}, |
||||
{ |
||||
"name": "Luke Edwards", |
||||
"url": "https://lukeed.com" |
||||
} |
||||
], |
||||
"deprecated": false, |
||||
"description": "Recursively flatten an array or arrays.", |
||||
"devDependencies": { |
||||
"ansi-bold": "^0.1.1", |
||||
"array-flatten": "^2.1.1", |
||||
"array-slice": "^1.0.0", |
||||
"benchmarked": "^1.0.0", |
||||
"compute-flatten": "^1.0.0", |
||||
"flatit": "^1.1.1", |
||||
"flatten": "^1.0.2", |
||||
"flatten-array": "^1.0.0", |
||||
"glob": "^7.1.1", |
||||
"gulp-format-md": "^0.1.12", |
||||
"just-flatten-it": "^1.1.23", |
||||
"lodash.flattendeep": "^4.4.0", |
||||
"m_flattened": "^1.0.1", |
||||
"mocha": "^3.2.0", |
||||
"utils-flatten": "^1.0.0", |
||||
"write": "^0.3.3" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.10.0" |
||||
}, |
||||
"files": [ |
||||
"index.js" |
||||
], |
||||
"homepage": "https://github.com/jonschlinkert/arr-flatten", |
||||
"keywords": [ |
||||
"arr", |
||||
"array", |
||||
"elements", |
||||
"flat", |
||||
"flatten", |
||||
"nested", |
||||
"recurse", |
||||
"recursive", |
||||
"recursively" |
||||
], |
||||
"license": "MIT", |
||||
"main": "index.js", |
||||
"name": "arr-flatten", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git+https://github.com/jonschlinkert/arr-flatten.git" |
||||
}, |
||||
"scripts": { |
||||
"test": "mocha" |
||||
}, |
||||
"verb": { |
||||
"toc": false, |
||||
"layout": "default", |
||||
"tasks": [ |
||||
"readme" |
||||
], |
||||
"plugins": [ |
||||
"gulp-format-md" |
||||
], |
||||
"related": { |
||||
"list": [ |
||||
"arr-filter", |
||||
"arr-union", |
||||
"array-each", |
||||
"array-unique" |
||||
] |
||||
}, |
||||
"lint": { |
||||
"reflinks": true |
||||
} |
||||
}, |
||||
"version": "1.1.0" |
||||
} |
@ -0,0 +1,44 @@ |
||||
{ |
||||
"env": { |
||||
"browser": true, |
||||
"node": true, |
||||
"commonjs": true, |
||||
"es6": true |
||||
}, |
||||
"extends": "eslint:recommended", |
||||
"rules": { |
||||
"strict": 2, |
||||
"indent": 0, |
||||
"linebreak-style": 0, |
||||
"quotes": 0, |
||||
"semi": 0, |
||||
"no-cond-assign": 1, |
||||
"no-constant-condition": 1, |
||||
"no-duplicate-case": 1, |
||||
"no-empty": 1, |
||||
"no-ex-assign": 1, |
||||
"no-extra-boolean-cast": 1, |
||||
"no-extra-semi": 1, |
||||
"no-fallthrough": 1, |
||||
"no-func-assign": 1, |
||||
"no-global-assign": 1, |
||||
"no-implicit-globals": 2, |
||||
"no-inner-declarations": ["error", "functions"], |
||||
"no-irregular-whitespace": 2, |
||||
"no-loop-func": 1, |
||||
"no-magic-numbers": ["warn", { "ignore": [1, 0, -1], "ignoreArrayIndexes": true}], |
||||
"no-multi-str": 1, |
||||
"no-mixed-spaces-and-tabs": 1, |
||||
"no-proto": 1, |
||||
"no-sequences": 1, |
||||
"no-throw-literal": 1, |
||||
"no-unmodified-loop-condition": 1, |
||||
"no-useless-call": 1, |
||||
"no-void": 1, |
||||
"no-with": 2, |
||||
"wrap-iife": 1, |
||||
"no-redeclare": 1, |
||||
"no-unused-vars": ["error", { "vars": "all", "args": "none" }], |
||||
"no-sparse-arrays": 1 |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
language: node_js |
||||
node_js: |
||||
- '6' |
||||
- '5' |
||||
- '4' |
@ -0,0 +1,45 @@ |
||||
/** |
||||
* @module arraybuffer-to-string/browser |
||||
*/ |
||||
|
||||
'use strict' |
||||
|
||||
module.exports = function ArrayBufferToString (buffer, encoding) { |
||||
if (encoding == null) encoding = 'utf8' |
||||
|
||||
var uint8 = new Uint8Array(buffer) |
||||
|
||||
if (encoding === 'hex') { |
||||
var out = '' |
||||
for (var i = 0, l = uint8.byteLength; i < l; ++i) { |
||||
out += toHex(uint8[i]) |
||||
} |
||||
return out |
||||
} |
||||
|
||||
if (encoding === 'base64') { |
||||
str = String.fromCharCode.apply(null, uint8) |
||||
return btoa(str) |
||||
} |
||||
|
||||
if (encoding === 'binary' || |
||||
encoding === 'latin1' || |
||||
!global.TextDecoder) { |
||||
str = String.fromCharCode.apply(null, uint8) |
||||
return str |
||||
} |
||||
|
||||
|
||||
//TextDecoder way
|
||||
if (encoding === 'utf16le') encoding = 'utf-16le' |
||||
|
||||
var decoder = new TextDecoder(encoding) |
||||
var str = decoder.decode(uint8) |
||||
return str |
||||
} |
||||
|
||||
|
||||
function toHex (n) { |
||||
if (n < 16) return '0' + n.toString(16) |
||||
return n.toString(16) |
||||
} |
@ -0,0 +1,11 @@ |
||||
/** |
||||
* @module arraybuffer-to-string |
||||
*/ |
||||
|
||||
'use strict' |
||||
|
||||
module.exports = function ArrayBufferToString (buffer, encoding) { |
||||
if (encoding == null) encoding = 'utf8' |
||||
|
||||
return Buffer.from(buffer).toString(encoding) |
||||
} |
@ -0,0 +1,65 @@ |
||||
{ |
||||
"_from": "arraybuffer-to-string@^1.0.2", |
||||
"_id": "arraybuffer-to-string@1.0.2", |
||||
"_inBundle": false, |
||||
"_integrity": "sha512-WbIYlLVmvIAyUBdQRRuyGOJRriOQy9OAsWcyURmsRQp9+g647hdMSS2VFKXbJLVw0daUu06hqwLXm9etVrXI9A==", |
||||
"_location": "/arraybuffer-to-string", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "range", |
||||
"registry": true, |
||||
"raw": "arraybuffer-to-string@^1.0.2", |
||||
"name": "arraybuffer-to-string", |
||||
"escapedName": "arraybuffer-to-string", |
||||
"rawSpec": "^1.0.2", |
||||
"saveSpec": null, |
||||
"fetchSpec": "^1.0.2" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/image-pixels" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/arraybuffer-to-string/-/arraybuffer-to-string-1.0.2.tgz", |
||||
"_shasum": "c373aa7bb0e6844d9a2bc9654c8889a9570a26e2", |
||||
"_spec": "arraybuffer-to-string@^1.0.2", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-pixels", |
||||
"author": { |
||||
"name": "Dima Yv", |
||||
"email": "dfcreative@gmail.com" |
||||
}, |
||||
"browser": "./browser.js", |
||||
"bugs": { |
||||
"url": "https://github.com/dfcreative/arraybuffer-to-string/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"deprecated": false, |
||||
"description": "Convert ArrayBuffer to string", |
||||
"devDependencies": { |
||||
"buffer-to-arraybuffer": "0.0.4", |
||||
"is-browser": "^2.0.1", |
||||
"string-to-arraybuffer": "^1.0.0", |
||||
"tape": "^4.7.0" |
||||
}, |
||||
"homepage": "https://github.com/dfcreative/arraybuffer-to-string#readme", |
||||
"keywords": [ |
||||
"arraybuffer", |
||||
"array-buffer", |
||||
"array", |
||||
"buffer", |
||||
"string", |
||||
"base64", |
||||
"atob", |
||||
"btoa", |
||||
"datauri" |
||||
], |
||||
"license": "MIT", |
||||
"main": "index.js", |
||||
"name": "arraybuffer-to-string", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git+https://github.com/dfcreative/arraybuffer-to-string.git" |
||||
}, |
||||
"scripts": { |
||||
"test": "node test.js" |
||||
}, |
||||
"version": "1.0.2" |
||||
} |
@ -0,0 +1,27 @@ |
||||
# arraybuffer-to-string [![unstable](https://img.shields.io/badge/stability-unstable-orange.svg)](http://github.com/badges/stability-badges) [![Build Status](https://img.shields.io/travis/dfcreative/arraybuffer-to-string.svg)](https://travis-ci.org/dfcreative/arraybuffer-to-string) |
||||
|
||||
Convert _ArrayBuffer_ to string with optional encoding. |
||||
|
||||
[![npm install arraybuffer-to-string](https://nodei.co/npm/arraybuffer-to-string.png?mini=true)](https://npmjs.org/package/arraybuffer-to-string/) |
||||
|
||||
```js |
||||
var ab2str = require('arraybuffer-to-string') |
||||
|
||||
var uint8 = new Uint8Array([ 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33 ]) |
||||
|
||||
ab2str(uint8) // 'Hello World!' |
||||
ab2str(uint8, 'base64') // 'SGVsbG8gV29ybGQh' |
||||
ab2str(uint8, 'hex') // '48656c6c6f20576f726c6421' |
||||
ab2str(uint8, 'iso-8859-2') // 'Hello World!' |
||||
``` |
||||
|
||||
### var str = arrayBufferToString(buffer, encoding='utf8') |
||||
|
||||
Convert ArrayBuffer/ArrayBufferView/Array `buffer` to string with defined encoding. Available encoding: `utf8`, `binary`, `base64`, `hex`, `ascii`, `latin1`, `ucs2`, `utf16` and [many others](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/encoding). |
||||
|
||||
Note: in browser it relies on [TextDecoder API](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode), so if you are dealing with charsets other than `utf8`, `ascii`, `binary` or `base64` in old browsers, please include [encoding polyfill](https://github.com/inexorabletash/text-encoding). |
||||
|
||||
### Related |
||||
|
||||
* [string-to-arraybuffer](https://github.com/dfcreative/string-to-arraybuffer) − convert string to arraybuffer. |
||||
* [create-data-uri](https://www.npmjs.com/package/create-data-uri) − convert binary data to datauri string. |
@ -0,0 +1,6 @@ |
||||
node_modules |
||||
*.log |
||||
.DS_Store |
||||
bundle.js |
||||
test |
||||
test.js |
@ -0,0 +1,18 @@ |
||||
This software is released under the MIT license: |
||||
|
||||
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. |
@ -0,0 +1,37 @@ |
||||
# atob-lite |
||||
![](http://img.shields.io/badge/stability-stable-orange.svg?style=flat) |
||||
![](http://img.shields.io/npm/v/atob-lite.svg?style=flat) |
||||
![](http://img.shields.io/npm/dm/atob-lite.svg?style=flat) |
||||
![](http://img.shields.io/npm/l/atob-lite.svg?style=flat) |
||||
|
||||
Smallest/simplest possible means of using atob with both Node and browserify. |
||||
|
||||
In the browser, decoding base64 strings is done using: |
||||
|
||||
``` javascript |
||||
var decoded = atob(encoded) |
||||
``` |
||||
|
||||
However in Node, it's done like so: |
||||
|
||||
``` javascript |
||||
var decoded = new Buffer(encoded, 'base64').toString('utf8') |
||||
``` |
||||
|
||||
You can easily check if `Buffer` exists and switch between the approaches |
||||
accordingly, but using `Buffer` anywhere in your browser source will pull |
||||
in browserify's `Buffer` shim which is pretty hefty. This package uses |
||||
the `main` and `browser` fields in its `package.json` to perform this |
||||
check at build time and avoid pulling `Buffer` in unnecessarily. |
||||
|
||||
## Usage |
||||
|
||||
[![NPM](https://nodei.co/npm/atob-lite.png)](https://nodei.co/npm/atob-lite/) |
||||
|
||||
### `decoded = atob(encoded)` |
||||
|
||||
Returns the decoded value of a base64-encoded string. |
||||
|
||||
## License |
||||
|
||||
MIT. See [LICENSE.md](http://github.com/hughsk/atob-lite/blob/master/LICENSE.md) for details. |
@ -0,0 +1,3 @@ |
||||
module.exports = function _atob(str) { |
||||
return atob(str) |
||||
} |
@ -0,0 +1,3 @@ |
||||
module.exports = function atob(str) { |
||||
return Buffer.from(str, 'base64').toString('binary') |
||||
} |
@ -0,0 +1,67 @@ |
||||
{ |
||||
"_from": "atob-lite@^2.0.0", |
||||
"_id": "atob-lite@2.0.0", |
||||
"_inBundle": false, |
||||
"_integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=", |
||||
"_location": "/atob-lite", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "range", |
||||
"registry": true, |
||||
"raw": "atob-lite@^2.0.0", |
||||
"name": "atob-lite", |
||||
"escapedName": "atob-lite", |
||||
"rawSpec": "^2.0.0", |
||||
"saveSpec": null, |
||||
"fetchSpec": "^2.0.0" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/string-to-arraybuffer" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", |
||||
"_shasum": "0fef5ad46f1bd7a8502c65727f0367d5ee43d696", |
||||
"_spec": "atob-lite@^2.0.0", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/string-to-arraybuffer", |
||||
"author": { |
||||
"name": "Hugh Kennedy", |
||||
"email": "hughskennedy@gmail.com", |
||||
"url": "http://hughsk.io/" |
||||
}, |
||||
"browser": "atob-browser.js", |
||||
"bugs": { |
||||
"url": "https://github.com/hughsk/atob-lite/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"dependencies": {}, |
||||
"deprecated": false, |
||||
"description": "Smallest/simplest possible means of using atob with both Node and browserify", |
||||
"devDependencies": { |
||||
"browserify": "^10.2.4", |
||||
"smokestack": "^3.3.0", |
||||
"tap-closer": "^1.0.0", |
||||
"tap-spec": "^4.0.0", |
||||
"tape": "^4.0.0" |
||||
}, |
||||
"homepage": "https://github.com/hughsk/atob-lite", |
||||
"keywords": [ |
||||
"atob", |
||||
"base64", |
||||
"isomorphic", |
||||
"browser", |
||||
"node", |
||||
"shared" |
||||
], |
||||
"license": "MIT", |
||||
"main": "atob-node.js", |
||||
"name": "atob-lite", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git://github.com/hughsk/atob-lite.git" |
||||
}, |
||||
"scripts": { |
||||
"test": "npm run test-node && npm run test-browser", |
||||
"test-browser": "browserify test | smokestack | tap-spec", |
||||
"test-node": "node test | tap-spec" |
||||
}, |
||||
"version": "2.0.0" |
||||
} |
@ -0,0 +1,2 @@ |
||||
node_modules |
||||
.idea |
@ -0,0 +1,21 @@ |
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2014 @丝刀口 |
||||
|
||||
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. |
@ -0,0 +1,44 @@ |
||||
bmp-js |
||||
====== |
||||
|
||||
A pure javascript Bmp encoder and decoder for node.js |
||||
|
||||
Supports all bits decoding(1,4,8,16,24,32) and encoding with 24bit. |
||||
|
||||
##Install |
||||
|
||||
$ npm install bmp-js |
||||
|
||||
|
||||
How to use? |
||||
--- |
||||
###Decode BMP |
||||
```js |
||||
var bmp = require("bmp-js"); |
||||
var bmpBuffer = fs.readFileSync('bit24.bmp'); |
||||
var bmpData = bmp.decode(bmpBuffer); |
||||
|
||||
``` |
||||
|
||||
`bmpData` has all properties includes: |
||||
|
||||
1. fileSize,reserved,offset |
||||
|
||||
2. headerSize,width,height,planes,bitPP,compress,rawSize,hr,vr,colors,importantColors |
||||
|
||||
3. palette |
||||
|
||||
4. data-------byte array order by ABGR ABGR ABGR,4 bytes per pixel |
||||
|
||||
|
||||
###Encode RGB |
||||
```js |
||||
var bmp = require("bmp-js"); |
||||
//bmpData={data:Buffer,width:Number,height:Height} |
||||
var rawData = bmp.encode(bmpData);//default no compression,write rawData to .bmp file |
||||
|
||||
``` |
||||
|
||||
License |
||||
--- |
||||
U can use on free with [MIT License](https://github.com/shaozilee/bmp-js/blob/master/LICENSE) |
@ -0,0 +1,9 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<module type="WEB_MODULE" version="4"> |
||||
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
||||
<exclude-output /> |
||||
<content url="file://$MODULE_DIR$" /> |
||||
<orderEntry type="inheritedJdk" /> |
||||
<orderEntry type="sourceFolder" forTests="false" /> |
||||
</component> |
||||
</module> |
@ -0,0 +1,15 @@ |
||||
/** |
||||
* @author shaozilee |
||||
* |
||||
* support 1bit 4bit 8bit 24bit decode |
||||
* encode with 24bit |
||||
*
|
||||
*/ |
||||
|
||||
var encode = require('./lib/encoder'), |
||||
decode = require('./lib/decoder'); |
||||
|
||||
module.exports = { |
||||
encode: encode, |
||||
decode: decode |
||||
}; |
@ -0,0 +1,485 @@ |
||||
/** |
||||
* @author shaozilee |
||||
* |
||||
* Bmp format decoder,support 1bit 4bit 8bit 24bit bmp |
||||
* |
||||
*/ |
||||
|
||||
function BmpDecoder(buffer,is_with_alpha) { |
||||
this.pos = 0; |
||||
this.buffer = buffer; |
||||
this.is_with_alpha = !!is_with_alpha; |
||||
this.bottom_up = true; |
||||
this.flag = this.buffer.toString("utf-8", 0, this.pos += 2); |
||||
if (this.flag != "BM") throw new Error("Invalid BMP File"); |
||||
this.parseHeader(); |
||||
this.parseRGBA(); |
||||
} |
||||
|
||||
BmpDecoder.prototype.parseHeader = function() { |
||||
this.fileSize = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.reserved = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.offset = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.headerSize = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.width = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.height = this.buffer.readInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.planes = this.buffer.readUInt16LE(this.pos); |
||||
this.pos += 2; |
||||
this.bitPP = this.buffer.readUInt16LE(this.pos); |
||||
this.pos += 2; |
||||
this.compress = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.rawSize = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.hr = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.vr = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.colors = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
this.importantColors = this.buffer.readUInt32LE(this.pos); |
||||
this.pos += 4; |
||||
|
||||
if(this.bitPP === 16 && this.is_with_alpha){ |
||||
this.bitPP = 15 |
||||
} |
||||
if (this.bitPP < 15) { |
||||
var len = this.colors === 0 ? 1 << this.bitPP : this.colors; |
||||
this.palette = new Array(len); |
||||
for (var i = 0; i < len; i++) { |
||||
var blue = this.buffer.readUInt8(this.pos++); |
||||
var green = this.buffer.readUInt8(this.pos++); |
||||
var red = this.buffer.readUInt8(this.pos++); |
||||
var quad = this.buffer.readUInt8(this.pos++); |
||||
this.palette[i] = { |
||||
red: red, |
||||
green: green, |
||||
blue: blue, |
||||
quad: quad |
||||
}; |
||||
} |
||||
} |
||||
if(this.height < 0) { |
||||
this.height *= -1; |
||||
this.bottom_up = false; |
||||
} |
||||
|
||||
} |
||||
|
||||
BmpDecoder.prototype.parseRGBA = function() { |
||||
var bitn = "bit" + this.bitPP; |
||||
var len = this.width * this.height * 4; |
||||
this.data = new Buffer(len); |
||||
this[bitn](); |
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit1 = function() { |
||||
var xlen = Math.ceil(this.width / 8); |
||||
var mode = xlen%4; |
||||
var y = this.height >= 0 ? this.height - 1 : -this.height |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y |
||||
for (var x = 0; x < xlen; x++) { |
||||
var b = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x*8*4; |
||||
for (var i = 0; i < 8; i++) { |
||||
if(x*8+i<this.width){ |
||||
var rgb = this.palette[((b>>(7-i))&0x1)]; |
||||
|
||||
this.data[location+i*4] = 0; |
||||
this.data[location+i*4 + 1] = rgb.blue; |
||||
this.data[location+i*4 + 2] = rgb.green; |
||||
this.data[location+i*4 + 3] = rgb.red; |
||||
|
||||
}else{ |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (mode != 0){ |
||||
this.pos+=(4 - mode); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit4 = function() { |
||||
//RLE-4
|
||||
if(this.compress == 2){ |
||||
this.data.fill(0xff); |
||||
|
||||
var location = 0; |
||||
var lines = this.bottom_up?this.height-1:0; |
||||
var low_nibble = false;//for all count of pixel
|
||||
|
||||
while(location<this.data.length){ |
||||
var a = this.buffer.readUInt8(this.pos++); |
||||
var b = this.buffer.readUInt8(this.pos++); |
||||
//absolute mode
|
||||
if(a == 0){ |
||||
if(b == 0){//line end
|
||||
if(this.bottom_up){ |
||||
lines--; |
||||
}else{ |
||||
lines++; |
||||
} |
||||
location = lines*this.width*4; |
||||
low_nibble = false; |
||||
continue; |
||||
}else if(b == 1){//image end
|
||||
break; |
||||
}else if(b ==2){ |
||||
//offset x,y
|
||||
var x = this.buffer.readUInt8(this.pos++); |
||||
var y = this.buffer.readUInt8(this.pos++); |
||||
if(this.bottom_up){ |
||||
lines-=y; |
||||
}else{ |
||||
lines+=y; |
||||
} |
||||
|
||||
location +=(y*this.width*4+x*4); |
||||
}else{ |
||||
var c = this.buffer.readUInt8(this.pos++); |
||||
for(var i=0;i<b;i++){ |
||||
if (low_nibble) { |
||||
setPixelData.call(this, (c & 0x0f)); |
||||
} else { |
||||
setPixelData.call(this, (c & 0xf0)>>4); |
||||
} |
||||
|
||||
if ((i & 1) && (i+1 < b)){ |
||||
c = this.buffer.readUInt8(this.pos++); |
||||
} |
||||
|
||||
low_nibble = !low_nibble; |
||||
} |
||||
|
||||
if ((((b+1) >> 1) & 1 ) == 1){ |
||||
this.pos++ |
||||
} |
||||
} |
||||
|
||||
}else{//encoded mode
|
||||
for (var i = 0; i < a; i++) { |
||||
if (low_nibble) { |
||||
setPixelData.call(this, (b & 0x0f)); |
||||
} else { |
||||
setPixelData.call(this, (b & 0xf0)>>4); |
||||
} |
||||
low_nibble = !low_nibble; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
function setPixelData(rgbIndex){ |
||||
var rgb = this.palette[rgbIndex]; |
||||
this.data[location] = 0; |
||||
this.data[location + 1] = rgb.blue; |
||||
this.data[location + 2] = rgb.green; |
||||
this.data[location + 3] = rgb.red; |
||||
location+=4; |
||||
} |
||||
}else{ |
||||
|
||||
var xlen = Math.ceil(this.width/2); |
||||
var mode = xlen%4; |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y |
||||
for (var x = 0; x < xlen; x++) { |
||||
var b = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x*2*4; |
||||
|
||||
var before = b>>4; |
||||
var after = b&0x0F; |
||||
|
||||
var rgb = this.palette[before]; |
||||
this.data[location] = 0; |
||||
this.data[location + 1] = rgb.blue; |
||||
this.data[location + 2] = rgb.green; |
||||
this.data[location + 3] = rgb.red; |
||||
|
||||
|
||||
if(x*2+1>=this.width)break; |
||||
|
||||
rgb = this.palette[after]; |
||||
|
||||
this.data[location+4] = 0; |
||||
this.data[location+4 + 1] = rgb.blue; |
||||
this.data[location+4 + 2] = rgb.green; |
||||
this.data[location+4 + 3] = rgb.red; |
||||
|
||||
} |
||||
|
||||
if (mode != 0){ |
||||
this.pos+=(4 - mode); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit8 = function() { |
||||
//RLE-8
|
||||
if(this.compress == 1){ |
||||
this.data.fill(0xff); |
||||
|
||||
var location = 0; |
||||
var lines = this.bottom_up?this.height-1:0; |
||||
|
||||
while(location<this.data.length){ |
||||
var a = this.buffer.readUInt8(this.pos++); |
||||
var b = this.buffer.readUInt8(this.pos++); |
||||
//absolute mode
|
||||
if(a == 0){ |
||||
if(b == 0){//line end
|
||||
if(this.bottom_up){ |
||||
lines--; |
||||
}else{ |
||||
lines++; |
||||
} |
||||
location = lines*this.width*4; |
||||
continue; |
||||
}else if(b == 1){//image end
|
||||
break; |
||||
}else if(b ==2){ |
||||
//offset x,y
|
||||
var x = this.buffer.readUInt8(this.pos++); |
||||
var y = this.buffer.readUInt8(this.pos++); |
||||
if(this.bottom_up){ |
||||
lines-=y; |
||||
}else{ |
||||
lines+=y; |
||||
} |
||||
|
||||
location +=(y*this.width*4+x*4); |
||||
}else{ |
||||
for(var i=0;i<b;i++){ |
||||
var c = this.buffer.readUInt8(this.pos++); |
||||
setPixelData.call(this, c); |
||||
} |
||||
if(b&1 == 1){ |
||||
this.pos++; |
||||
} |
||||
|
||||
} |
||||
|
||||
}else{//encoded mode
|
||||
for (var i = 0; i < a; i++) { |
||||
setPixelData.call(this, b); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
function setPixelData(rgbIndex){ |
||||
var rgb = this.palette[rgbIndex]; |
||||
this.data[location] = 0; |
||||
this.data[location + 1] = rgb.blue; |
||||
this.data[location + 2] = rgb.green; |
||||
this.data[location + 3] = rgb.red; |
||||
location+=4; |
||||
} |
||||
}else { |
||||
var mode = this.width % 4; |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y |
||||
for (var x = 0; x < this.width; x++) { |
||||
var b = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x * 4; |
||||
if (b < this.palette.length) { |
||||
var rgb = this.palette[b]; |
||||
|
||||
this.data[location] = 0; |
||||
this.data[location + 1] = rgb.blue; |
||||
this.data[location + 2] = rgb.green; |
||||
this.data[location + 3] = rgb.red; |
||||
|
||||
} else { |
||||
this.data[location] = 0; |
||||
this.data[location + 1] = 0xFF; |
||||
this.data[location + 2] = 0xFF; |
||||
this.data[location + 3] = 0xFF; |
||||
} |
||||
} |
||||
if (mode != 0) { |
||||
this.pos += (4 - mode); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit15 = function() { |
||||
var dif_w =this.width % 3; |
||||
var _11111 = parseInt("11111", 2),_1_5 = _11111; |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y |
||||
for (var x = 0; x < this.width; x++) { |
||||
|
||||
var B = this.buffer.readUInt16LE(this.pos); |
||||
this.pos+=2; |
||||
var blue = (B & _1_5) / _1_5 * 255 | 0; |
||||
var green = (B >> 5 & _1_5 ) / _1_5 * 255 | 0; |
||||
var red = (B >> 10 & _1_5) / _1_5 * 255 | 0; |
||||
var alpha = (B>>15)?0xFF:0x00; |
||||
|
||||
var location = line * this.width * 4 + x * 4; |
||||
|
||||
this.data[location] = alpha; |
||||
this.data[location + 1] = blue; |
||||
this.data[location + 2] = green; |
||||
this.data[location + 3] = red; |
||||
} |
||||
//skip extra bytes
|
||||
this.pos += dif_w; |
||||
} |
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit16 = function() { |
||||
var dif_w =(this.width % 2)*2; |
||||
//default xrgb555
|
||||
this.maskRed = 0x7C00; |
||||
this.maskGreen = 0x3E0; |
||||
this.maskBlue =0x1F; |
||||
this.mask0 = 0; |
||||
|
||||
if(this.compress == 3){ |
||||
this.maskRed = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.maskGreen = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.maskBlue = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.mask0 = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
} |
||||
|
||||
|
||||
var ns=[0,0,0]; |
||||
for (var i=0;i<16;i++){ |
||||
if ((this.maskRed>>i)&0x01) ns[0]++; |
||||
if ((this.maskGreen>>i)&0x01) ns[1]++; |
||||
if ((this.maskBlue>>i)&0x01) ns[2]++; |
||||
} |
||||
ns[1]+=ns[0]; ns[2]+=ns[1]; ns[0]=8-ns[0]; ns[1]-=8; ns[2]-=8; |
||||
|
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y; |
||||
for (var x = 0; x < this.width; x++) { |
||||
|
||||
var B = this.buffer.readUInt16LE(this.pos); |
||||
this.pos+=2; |
||||
|
||||
var blue = (B&this.maskBlue)<<ns[0]; |
||||
var green = (B&this.maskGreen)>>ns[1]; |
||||
var red = (B&this.maskRed)>>ns[2]; |
||||
|
||||
var location = line * this.width * 4 + x * 4; |
||||
|
||||
this.data[location] = 0; |
||||
this.data[location + 1] = blue; |
||||
this.data[location + 2] = green; |
||||
this.data[location + 3] = red; |
||||
} |
||||
//skip extra bytes
|
||||
this.pos += dif_w; |
||||
} |
||||
}; |
||||
|
||||
BmpDecoder.prototype.bit24 = function() { |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y |
||||
for (var x = 0; x < this.width; x++) { |
||||
//Little Endian rgb
|
||||
var blue = this.buffer.readUInt8(this.pos++); |
||||
var green = this.buffer.readUInt8(this.pos++); |
||||
var red = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x * 4; |
||||
this.data[location] = 0; |
||||
this.data[location + 1] = blue; |
||||
this.data[location + 2] = green; |
||||
this.data[location + 3] = red; |
||||
} |
||||
//skip extra bytes
|
||||
this.pos += (this.width % 4); |
||||
} |
||||
|
||||
}; |
||||
|
||||
/** |
||||
* add 32bit decode func |
||||
* @author soubok |
||||
*/ |
||||
BmpDecoder.prototype.bit32 = function() { |
||||
//BI_BITFIELDS
|
||||
if(this.compress == 3){ |
||||
this.maskRed = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.maskGreen = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.maskBlue = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
this.mask0 = this.buffer.readUInt32LE(this.pos); |
||||
this.pos+=4; |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y; |
||||
for (var x = 0; x < this.width; x++) { |
||||
//Little Endian rgba
|
||||
var alpha = this.buffer.readUInt8(this.pos++); |
||||
var blue = this.buffer.readUInt8(this.pos++); |
||||
var green = this.buffer.readUInt8(this.pos++); |
||||
var red = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x * 4; |
||||
this.data[location] = alpha; |
||||
this.data[location + 1] = blue; |
||||
this.data[location + 2] = green; |
||||
this.data[location + 3] = red; |
||||
} |
||||
} |
||||
|
||||
}else{ |
||||
for (var y = this.height - 1; y >= 0; y--) { |
||||
var line = this.bottom_up ? y : this.height - 1 - y; |
||||
for (var x = 0; x < this.width; x++) { |
||||
//Little Endian argb
|
||||
var blue = this.buffer.readUInt8(this.pos++); |
||||
var green = this.buffer.readUInt8(this.pos++); |
||||
var red = this.buffer.readUInt8(this.pos++); |
||||
var alpha = this.buffer.readUInt8(this.pos++); |
||||
var location = line * this.width * 4 + x * 4; |
||||
this.data[location] = alpha; |
||||
this.data[location + 1] = blue; |
||||
this.data[location + 2] = green; |
||||
this.data[location + 3] = red; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
}; |
||||
|
||||
BmpDecoder.prototype.getData = function() { |
||||
return this.data; |
||||
}; |
||||
|
||||
module.exports = function(bmpData) { |
||||
var decoder = new BmpDecoder(bmpData); |
||||
return decoder; |
||||
}; |
@ -0,0 +1,81 @@ |
||||
/** |
||||
* @author shaozilee |
||||
* |
||||
* BMP format encoder,encode 24bit BMP |
||||
* Not support quality compression |
||||
* |
||||
*/ |
||||
|
||||
function BmpEncoder(imgData){ |
||||
this.buffer = imgData.data; |
||||
this.width = imgData.width; |
||||
this.height = imgData.height; |
||||
this.extraBytes = this.width%4; |
||||
this.rgbSize = this.height*(3*this.width+this.extraBytes); |
||||
this.headerInfoSize = 40; |
||||
|
||||
this.data = []; |
||||
/******************header***********************/ |
||||
this.flag = "BM"; |
||||
this.reserved = 0; |
||||
this.offset = 54; |
||||
this.fileSize = this.rgbSize+this.offset; |
||||
this.planes = 1; |
||||
this.bitPP = 24; |
||||
this.compress = 0; |
||||
this.hr = 0; |
||||
this.vr = 0; |
||||
this.colors = 0; |
||||
this.importantColors = 0; |
||||
} |
||||
|
||||
BmpEncoder.prototype.encode = function() { |
||||
var tempBuffer = new Buffer(this.offset+this.rgbSize); |
||||
this.pos = 0; |
||||
tempBuffer.write(this.flag,this.pos,2);this.pos+=2; |
||||
tempBuffer.writeUInt32LE(this.fileSize,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.reserved,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.offset,this.pos);this.pos+=4; |
||||
|
||||
tempBuffer.writeUInt32LE(this.headerInfoSize,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.width,this.pos);this.pos+=4; |
||||
tempBuffer.writeInt32LE(-this.height,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt16LE(this.planes,this.pos);this.pos+=2; |
||||
tempBuffer.writeUInt16LE(this.bitPP,this.pos);this.pos+=2; |
||||
tempBuffer.writeUInt32LE(this.compress,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.rgbSize,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.hr,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.vr,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.colors,this.pos);this.pos+=4; |
||||
tempBuffer.writeUInt32LE(this.importantColors,this.pos);this.pos+=4; |
||||
|
||||
var i=0; |
||||
var rowBytes = 3*this.width+this.extraBytes; |
||||
|
||||
for (var y = 0; y <this.height; y++){ |
||||
for (var x = 0; x < this.width; x++){ |
||||
var p = this.pos+y*rowBytes+x*3; |
||||
i++;//a
|
||||
tempBuffer[p]= this.buffer[i++];//b
|
||||
tempBuffer[p+1] = this.buffer[i++];//g
|
||||
tempBuffer[p+2] = this.buffer[i++];//r
|
||||
} |
||||
if(this.extraBytes>0){ |
||||
var fillOffset = this.pos+y*rowBytes+this.width*3; |
||||
tempBuffer.fill(0,fillOffset,fillOffset+this.extraBytes); |
||||
} |
||||
} |
||||
|
||||
return tempBuffer; |
||||
}; |
||||
|
||||
module.exports = function(imgData, quality) { |
||||
if (typeof quality === 'undefined') quality = 100; |
||||
var encoder = new BmpEncoder(imgData); |
||||
var data = encoder.encode(); |
||||
return { |
||||
data: data, |
||||
width: imgData.width, |
||||
height: imgData.height |
||||
}; |
||||
}; |
@ -0,0 +1,60 @@ |
||||
{ |
||||
"_from": "bmp-js@^0.1.0", |
||||
"_id": "bmp-js@0.1.0", |
||||
"_inBundle": false, |
||||
"_integrity": "sha1-4Fpj95amwf8l9Hcex62twUjAcjM=", |
||||
"_location": "/bmp-js", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "range", |
||||
"registry": true, |
||||
"raw": "bmp-js@^0.1.0", |
||||
"name": "bmp-js", |
||||
"escapedName": "bmp-js", |
||||
"rawSpec": "^0.1.0", |
||||
"saveSpec": null, |
||||
"fetchSpec": "^0.1.0" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/image-decode" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz", |
||||
"_shasum": "e05a63f796a6c1ff25f4771ec7adadc148c07233", |
||||
"_spec": "bmp-js@^0.1.0", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-decode", |
||||
"author": { |
||||
"name": "shaozilee", |
||||
"email": "shaozilee@gmail.com" |
||||
}, |
||||
"bugs": { |
||||
"url": "https://github.com/shaozilee/bmp-js/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"dependencies": {}, |
||||
"deprecated": false, |
||||
"description": "A pure javascript BMP encoder and decoder", |
||||
"devDependencies": {}, |
||||
"homepage": "https://github.com/shaozilee/bmp-js#readme", |
||||
"keywords": [ |
||||
"bmp", |
||||
"1bit", |
||||
"4bit", |
||||
"8bit", |
||||
"16bit", |
||||
"24bit", |
||||
"32bit", |
||||
"encoder", |
||||
"decoder", |
||||
"image", |
||||
"javascript", |
||||
"js" |
||||
], |
||||
"license": "MIT", |
||||
"main": "index.js", |
||||
"name": "bmp-js", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git+https://github.com/shaozilee/bmp-js.git" |
||||
}, |
||||
"version": "0.1.0" |
||||
} |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
@ -0,0 +1,33 @@ |
||||
var fs = require("fs"); |
||||
|
||||
var coder = require("../index.js"); |
||||
var bmps = ["./bit1", "./bit4", "./bit4_RLE", "./bit8", "./bit8_RLE", "./bit16_565", "./bit16_a444", "./bit16_a555", "./bit16_x444", "./bit16_x555", "./bit24", "./bit32", "./bit32_alpha"]; |
||||
|
||||
console.log("test bmp decoding and encoding..."); |
||||
|
||||
for(var b=0; b<bmps.length;b++){ |
||||
var src =bmps[b]; |
||||
console.log("----------------"+src+".bmp"); |
||||
var bufferData = fs.readFileSync(src+".bmp"); |
||||
var decoder = coder.decode(bufferData); |
||||
console.log("width:",decoder.width); |
||||
console.log("height",decoder.height); |
||||
console.log("fileSize:",decoder.fileSize); |
||||
|
||||
|
||||
//encode with 24bit
|
||||
var encodeData = coder.encode(decoder); |
||||
fs.writeFileSync(src+"_out.bmp", encodeData.data); |
||||
} |
||||
|
||||
console.log("test bmp success!"); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,4 @@ |
||||
language: node_js |
||||
node_js: |
||||
- 0.8 |
||||
- "0.10" |
@ -0,0 +1,62 @@ |
||||
buffer-equal |
||||
============ |
||||
|
||||
Return whether two buffers are equal. |
||||
|
||||
[![build status](https://secure.travis-ci.org/substack/node-buffer-equal.png)](http://travis-ci.org/substack/node-buffer-equal) |
||||
|
||||
example |
||||
======= |
||||
|
||||
``` js |
||||
var bufferEqual = require('buffer-equal'); |
||||
|
||||
console.dir(bufferEqual( |
||||
new Buffer([253,254,255]), |
||||
new Buffer([253,254,255]) |
||||
)); |
||||
console.dir(bufferEqual( |
||||
new Buffer('abc'), |
||||
new Buffer('abcd') |
||||
)); |
||||
console.dir(bufferEqual( |
||||
new Buffer('abc'), |
||||
'abc' |
||||
)); |
||||
``` |
||||
|
||||
output: |
||||
|
||||
``` |
||||
true |
||||
false |
||||
undefined |
||||
``` |
||||
|
||||
methods |
||||
======= |
||||
|
||||
``` js |
||||
var bufferEqual = require('buffer-equal') |
||||
``` |
||||
|
||||
bufferEqual(a, b) |
||||
----------------- |
||||
|
||||
Return whether the two buffers `a` and `b` are equal. |
||||
|
||||
If `a` or `b` is not a buffer, return `undefined`. |
||||
|
||||
install |
||||
======= |
||||
|
||||
With [npm](http://npmjs.org) do: |
||||
|
||||
``` |
||||
npm install buffer-equal |
||||
``` |
||||
|
||||
license |
||||
======= |
||||
|
||||
MIT |
@ -0,0 +1,14 @@ |
||||
var bufferEqual = require('../'); |
||||
|
||||
console.dir(bufferEqual( |
||||
new Buffer([253,254,255]), |
||||
new Buffer([253,254,255]) |
||||
)); |
||||
console.dir(bufferEqual( |
||||
new Buffer('abc'), |
||||
new Buffer('abcd') |
||||
)); |
||||
console.dir(bufferEqual( |
||||
new Buffer('abc'), |
||||
'abc' |
||||
)); |
@ -0,0 +1,14 @@ |
||||
var Buffer = require('buffer').Buffer; // for use with browserify
|
||||
|
||||
module.exports = function (a, b) { |
||||
if (!Buffer.isBuffer(a)) return undefined; |
||||
if (!Buffer.isBuffer(b)) return undefined; |
||||
if (typeof a.equals === 'function') return a.equals(b); |
||||
if (a.length !== b.length) return false; |
||||
|
||||
for (var i = 0; i < a.length; i++) { |
||||
if (a[i] !== b[i]) return false; |
||||
} |
||||
|
||||
return true; |
||||
}; |
@ -0,0 +1,62 @@ |
||||
{ |
||||
"_from": "buffer-equal@0.0.1", |
||||
"_id": "buffer-equal@0.0.1", |
||||
"_inBundle": false, |
||||
"_integrity": "sha1-kbx0sR6kBbyRa8aqkI+q+ltKrEs=", |
||||
"_location": "/buffer-equal", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "version", |
||||
"registry": true, |
||||
"raw": "buffer-equal@0.0.1", |
||||
"name": "buffer-equal", |
||||
"escapedName": "buffer-equal", |
||||
"rawSpec": "0.0.1", |
||||
"saveSpec": null, |
||||
"fetchSpec": "0.0.1" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/readimage" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz", |
||||
"_shasum": "91bc74b11ea405bc916bc6aa908faafa5b4aac4b", |
||||
"_spec": "buffer-equal@0.0.1", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/readimage", |
||||
"author": { |
||||
"name": "James Halliday", |
||||
"email": "mail@substack.net", |
||||
"url": "http://substack.net" |
||||
}, |
||||
"bugs": { |
||||
"url": "https://github.com/substack/node-buffer-equal/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"deprecated": false, |
||||
"description": "return whether two buffers are equal", |
||||
"devDependencies": { |
||||
"tap": "0.2.4" |
||||
}, |
||||
"directories": { |
||||
"example": "example", |
||||
"test": "test" |
||||
}, |
||||
"engines": { |
||||
"node": ">=0.4.0" |
||||
}, |
||||
"homepage": "https://github.com/substack/node-buffer-equal#readme", |
||||
"keywords": [ |
||||
"buffer", |
||||
"equal" |
||||
], |
||||
"license": "MIT", |
||||
"main": "index.js", |
||||
"name": "buffer-equal", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git://github.com/substack/node-buffer-equal.git" |
||||
}, |
||||
"scripts": { |
||||
"test": "tap test/*.js" |
||||
}, |
||||
"version": "0.0.1" |
||||
} |
@ -0,0 +1,35 @@ |
||||
var bufferEqual = require('../'); |
||||
var test = require('tap').test; |
||||
|
||||
test('equal', function (t) { |
||||
var eq = bufferEqual( |
||||
new Buffer([253,254,255]), |
||||
new Buffer([253,254,255]) |
||||
); |
||||
t.strictEqual(eq, true); |
||||
t.end(); |
||||
}); |
||||
|
||||
test('not equal', function (t) { |
||||
var eq = bufferEqual( |
||||
new Buffer('abc'), |
||||
new Buffer('abcd') |
||||
); |
||||
t.strictEqual(eq, false); |
||||
t.end(); |
||||
}); |
||||
|
||||
test('not equal not buffer', function (t) { |
||||
var eq = bufferEqual( |
||||
new Buffer('abc'), |
||||
'abc' |
||||
); |
||||
t.strictEqual(eq, undefined); |
||||
t.end(); |
||||
}); |
||||
|
||||
test('equal not buffer', function (t) { |
||||
var eq = bufferEqual('abc', 'abc'); |
||||
t.strictEqual(eq, undefined); |
||||
t.end(); |
||||
}); |
@ -0,0 +1,18 @@ |
||||
This software is released under the MIT license: |
||||
|
||||
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. |
@ -0,0 +1,5 @@ |
||||
var tou8 = require('../'); |
||||
var buf = new Buffer('whatever'); |
||||
var a = tou8(buf); |
||||
console.log(a.constructor.name); |
||||
console.log(a); |
@ -0,0 +1,11 @@ |
||||
module.exports = function (buf) { |
||||
if (!buf) return undefined; |
||||
if (buf.constructor.name === 'Uint8Array' |
||||
|| buf.constructor === Uint8Array) { |
||||
return buf; |
||||
} |
||||
if (typeof buf === 'string') buf = Buffer(buf); |
||||
var a = new Uint8Array(buf.length); |
||||
for (var i = 0; i < buf.length; i++) a[i] = buf[i]; |
||||
return a; |
||||
}; |
@ -0,0 +1,60 @@ |
||||
{ |
||||
"_from": "buffer-to-uint8array@^1.1.0", |
||||
"_id": "buffer-to-uint8array@1.1.0", |
||||
"_inBundle": false, |
||||
"_integrity": "sha1-z29BKHwCL0WNp1LDkcGo1TXsX3I=", |
||||
"_location": "/buffer-to-uint8array", |
||||
"_phantomChildren": {}, |
||||
"_requested": { |
||||
"type": "range", |
||||
"registry": true, |
||||
"raw": "buffer-to-uint8array@^1.1.0", |
||||
"name": "buffer-to-uint8array", |
||||
"escapedName": "buffer-to-uint8array", |
||||
"rawSpec": "^1.1.0", |
||||
"saveSpec": null, |
||||
"fetchSpec": "^1.1.0" |
||||
}, |
||||
"_requiredBy": [ |
||||
"/image-decode" |
||||
], |
||||
"_resolved": "https://registry.npmjs.org/buffer-to-uint8array/-/buffer-to-uint8array-1.1.0.tgz", |
||||
"_shasum": "cf6f41287c022f458da752c391c1a8d535ec5f72", |
||||
"_spec": "buffer-to-uint8array@^1.1.0", |
||||
"_where": "/home/sigonasr2/divar/server/node_modules/image-decode", |
||||
"author": { |
||||
"name": "substack" |
||||
}, |
||||
"bugs": { |
||||
"url": "https://github.com/substack/buffer-to-uint8array/issues" |
||||
}, |
||||
"bundleDependencies": false, |
||||
"deprecated": false, |
||||
"description": "convert a buffer (or string) to a Uint8Array", |
||||
"devDependencies": { |
||||
"tape": "^4.0.0" |
||||
}, |
||||
"directories": { |
||||
"example": "example", |
||||
"test": "test" |
||||
}, |
||||
"homepage": "https://github.com/substack/buffer-to-uint8array#readme", |
||||
"keywords": [ |
||||
"Uint8Array", |
||||
"u8", |
||||
"byte", |
||||
"buffer", |
||||
"typedarray" |
||||
], |
||||
"license": "MIT", |
||||
"main": "index.js", |
||||
"name": "buffer-to-uint8array", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git://github.com/substack/buffer-to-uint8array.git" |
||||
}, |
||||
"scripts": { |
||||
"test": "tape test/*.js" |
||||
}, |
||||
"version": "1.1.0" |
||||
} |
@ -0,0 +1,37 @@ |
||||
# buffer-to-uint8array |
||||
|
||||
convert a buffer (or string) to a Uint8Array |
||||
|
||||
# example |
||||
|
||||
``` js |
||||
var tou8 = require('buffer-to-uint8array'); |
||||
var buf = new Buffer('whatever'); |
||||
var a = tou8(buf); |
||||
console.log(a.constructor.name); |
||||
console.log(a); |
||||
``` |
||||
|
||||
# methods |
||||
|
||||
``` js |
||||
var tou8 = require('buffer-to-uint8array') |
||||
``` |
||||
|
||||
## var u = tou8(buf) |
||||
|
||||
Convert `buf`, a `Buffer` or `string` to a `Uint8Array`. |
||||
|
||||
If `buf` is already a Uint8Array, it will be returned. |
||||
|
||||
# install |
||||
|
||||
With [npm](https://npmjs.org) do: |
||||
|
||||
``` |
||||
npm install buffer-to-uint8array |
||||
``` |
||||
|
||||
# license |
||||
|
||||
MIT |
@ -0,0 +1,10 @@ |
||||
var test = require('tape'); |
||||
var tou8 = require('../'); |
||||
|
||||
test('buffer to uint8', function (t) { |
||||
t.plan(2); |
||||
var buf = new Buffer('whatever'); |
||||
var a = tou8(buf); |
||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
||||
t.equal(a.length, 8, 'buffer length'); |
||||
}); |
@ -0,0 +1,10 @@ |
||||
var test = require('tape'); |
||||
var tou8 = require('../'); |
||||
|
||||
test('string to uint8', function (t) { |
||||
t.plan(2); |
||||
var str = 'whatever'; |
||||
var a = tou8(str); |
||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
||||
t.equal(a.length, 8, 'length'); |
||||
}); |
@ -0,0 +1,15 @@ |
||||
var test = require('tape'); |
||||
var tou8 = require('../'); |
||||
|
||||
test('uint8 to uint8', function (t) { |
||||
t.plan(3); |
||||
var a = new Uint8Array(8); |
||||
var buf = Buffer('whatever'); |
||||
for (var i = 0; i < buf.length; i++) a[i] = buf[i]; |
||||
|
||||
var b = tou8(a); |
||||
|
||||
t.equal(a, b, 'reference equality'); |
||||
t.equal(a.constructor.name, 'Uint8Array', 'constructor name'); |
||||
t.equal(a.length, 8, 'u8 length'); |
||||
}); |