Skip to content

Commit 77aaf22

Browse files
Marco MorettiMarco Moretti
authored andcommitted
First commit
0 parents  commit 77aaf22

37 files changed

+88820
-0
lines changed

.bower.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "canvas-to-bmp",
3+
"version": "1.1.0",
4+
"homepage": "https://github.com/epistemex/canvas-to-bmp",
5+
"authors": [
6+
"epistemex <[email protected]>"
7+
],
8+
"description": "Converts a canvas element to BMP with alpha",
9+
"main": "canvastobmp.min.js",
10+
"keywords": [
11+
"canvas",
12+
"bmp",
13+
"bitmap",
14+
"file"
15+
],
16+
"license": "MIT",
17+
"ignore": [
18+
"**/.*",
19+
"tests",
20+
"tuts"
21+
],
22+
"_release": "1.1.0",
23+
"_resolution": {
24+
"type": "version",
25+
"tag": "1.1.0",
26+
"commit": "47dad078e144d798de4dd5b9a4b7828aa343cda3"
27+
},
28+
"_source": "https://github.com/epistemex/canvas-to-bmp.git",
29+
"_target": "~1.1.0",
30+
"_originalSource": "canvas-to-bmp"
31+
}

Change.log

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Change log for CanvasToBMP
2+
--------------------------
3+
4+
1.1.0 BETA
5+
ADD: toObjectURL convenience method
6+
CHG: Minor internal changes
7+
8+
1.0.0 BETA
9+
CHG: All operations are now asynchronous
10+
CHG: Beta
11+
12+
1.0.0 ALPHA
13+
First version (synchronous) released on StackOverflow:
14+
https://stackoverflow.com/questions/29652307/canvas-unable-to-generate-bmp-image-dataurl-in-chrome/29652507#29652507
15+
16+
(c) Epistemex 2015

LICENSE-MIT.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Epistemex
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
canvas-to-bmp
2+
=============
3+
4+
Client side HTML5 Canvas to BMP file format converter with support for
5+
alpha channel.
6+
7+
Virtually all browsers can read BMP files, but not all browsers supports
8+
BMP with canvas' toDataURL().
9+
10+
The **canvas-to-bmp** plugin solves this when you need your canvas
11+
graphics as BMP.
12+
13+
14+
Features
15+
--------
16+
17+
- Fast and small!
18+
- All operations are asynchronous and non-blocking
19+
- Supports alpha channel
20+
- Can convert Canvas to BMP as ArrayBuffer
21+
- Can convert Canvas to BMP as Blob
22+
- Can convert Canvas to BMP as Data-URI
23+
- No dependencies
24+
- Documented source incl. HTML version (see docs/ folder)
25+
26+
27+
Install
28+
-------
29+
30+
**canvas-to-bmp** can be installed in various ways:
31+
32+
- Bower: `bower install canvas-to-bmp`
33+
- Git using HTTPS: `git clone https://github.com/epistemex/canvas-to-bmp.git`
34+
- Git using SSH: `git clone [email protected]:epistemex/canvas-to-bmp.git`
35+
- Download [zip archive](https://github.com/epistemex/canvas-to-bmp/archive/master.zip) and extract.
36+
- [canvastobmp.min.js](https://raw.githubusercontent.com/epistemex/canvas-to-bmp/master/canvastobmp.min.js)
37+
38+
39+
Usage
40+
-----
41+
42+
**canvas-to-bmp** is very easy to use. Just include the script in header
43+
or before the script section in your HTML file.
44+
45+
To convert the canvas to a BMP file, call:
46+
47+
CanvasToBMP.toDataURL(canvas, function(uri) {
48+
// uri is a Data-URI that can be used as source for images etc.
49+
// uri = "data:image/bmp;base64, ...etc...";
50+
});
51+
52+
A faster option to Data-URIs is using Blobs:
53+
54+
CanvasToBMP.toBlob(canvas, function(blob) {
55+
// blob object can be converted to an objectURL and then
56+
// set as source for images, or as download target:
57+
var url = URL.createObjectURL(blob);
58+
});
59+
60+
For convenience a direct Canvas to ObjectURL method is included:
61+
62+
CanvasToBMP.toObjectURL(canvas, function(url) {
63+
// can be used as source for image or download target
64+
});
65+
66+
Convert to an ArrayBuffer that can be sent over the net:
67+
68+
CanvasToBMP.toArrayBuffer(canvas, function(buffer) {
69+
// buffer is ArrayBuffer with the BMP file
70+
});
71+
72+
IMPORTANT: As with with ordinary canvas, cross-origin resource sharing
73+
(CORS) requirements must be fulfilled (see link below).
74+
75+
76+
Issues
77+
------
78+
79+
Feel free to report any issues you find.
80+
81+
Go to [issue tracker](https://github.com/epistemex/canvas-to-bmp/issues).
82+
83+
**Please note (these are not related to canvas-to-bmp):**
84+
85+
- Using large data-URIs can block the browser when it decodes them (use Blobs and ObjectURL instead)
86+
- Firefox (incl. v39) ignores the alpha channel in BMP files when reading them
87+
- [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) is a security mechanism in the browser.
88+
89+
90+
License
91+
-------
92+
93+
Released under [MIT license](http://choosealicense.com/licenses/mit/). You may use this class in both commercial and non-commercial projects provided that full header (minified and developer versions) is included.
94+
95+
96+
*&copy; Epistemex 2015*
97+
98+
![Epistemex](http://i.imgur.com/wZSsyt8.png)

bower.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "canvas-to-bmp",
3+
"version": "1.1.0",
4+
"homepage": "https://github.com/ictandmore/canvas-to-bmp",
5+
"authors": [
6+
"epistemex <[email protected]>"
7+
],
8+
"description": "Converts a canvas element to BMP with alpha",
9+
"main": "canvastobmp.min.js",
10+
"keywords": [
11+
"canvas", "bmp", "bitmap", "file"
12+
],
13+
"license": "MIT",
14+
"ignore": [
15+
"**/.*",
16+
"tests",
17+
"tuts"
18+
]
19+
}

canvastobmp.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)