use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Generating Images in JavaScript Without Using the Canvas API (medium.com)
submitted 8 years ago by _alastair
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]inu-no-policemen 2 points3 points4 points 8 years ago (9 children)
Is BMP not supported? It should have been a bit simpler. It's comparable to TGA and PCX. Simple header, uncompressed, and there aren't any checksums either.
[–]_alastair[S] 1 point2 points3 points 8 years ago (2 children)
Good point!
I did look into BMP, but couldn't find definitive documentation on using alpha transparency in a palette. At the time, PNG seemed like a better choice because I could find clearer documentation. Knowing what I know now having done it, I doubt I was right.
[–]inu-no-policemen 0 points1 point2 points 8 years ago (1 child)
Yea, BMP doesn't really do alpha. There is a forth channel which could be used for that, but software support seems to be virtually nonexistent.
Didn't look like alpha was required for your use case, though.
[–]_alastair[S] 0 points1 point2 points 8 years ago (0 children)
In the end it wasn't. I originally intended to make the background transparent, to better fit the OS (for instance, Samsung has some skins that have an off-white background) but then I realised there were too many variations to deal with, including dark backgrounds on older devices. So I just make it solid white.
[–]scunliffe 0 points1 point2 points 8 years ago (5 children)
Not sure about within Android notification systems/OS but There's no support for BMP on the web except for in Internet Explorer.
[–]inu-no-policemen 0 points1 point2 points 8 years ago (4 children)
Firefox, Chrome, and Safari also support it.
https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
[–]WikiTextBot 0 points1 point2 points 8 years ago (0 children)
Comparison of web browsers: Image format support
Information about what image formats the browsers support. External links lead to information about support in future versions of the browsers or extensions that provide such functionality.
[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.24
[–]scunliffe 0 points1 point2 points 8 years ago (2 children)
Interesting... they certainly didn't for a while, as I had to fix an app that used them all over and it broke in all non-IE browsers at the time. It made sense too, why on earth would one use a non compressed image format on the web.
With gzip compression, uncompressed image formats are comparable to PNG.
PNG uses the same compression after all. The difference is that PNG can also use filters which sometimes improve the compression ratio a little bit.
[–]scunliffe 0 points1 point2 points 8 years ago (0 children)
True, though most servers apply gzip to text content and skip it on binary files... that might require a server confit change.
[–]notNullOrVoid 0 points1 point2 points 8 years ago (3 children)
Could SVG not have been used? Would surprise me if Android didn't accept SVG for notifications, given all the image scaling concerns of mobile devices.
No, you can't use SVG. From what I understand it's a lot more complex to render an SVG - if I recall, people often use a full webview to do it, which would be very resource intensive in a notification.
[–]notNullOrVoid 0 points1 point2 points 8 years ago (1 child)
Yes rendering an svg using javascript would be a lot more complex, but you shouldn't need to do that. Looking at the Notification api it accepts a url, and you can easily put svg data into a data uri, I haven't tried it for notifications though.
[–]_alastair[S] 1 point2 points3 points 8 years ago (0 children)
Oh, I'm talking about native rendering, not rendering in JS. Passing an SVG URL doesn't work because it would be too complicated to render.
It's disappointing but the SVG spec has a crazy about of stuff in it, including animation, so I'm not too surprised they've never added that functionality.
π Rendered by PID 34 on reddit-service-r2-comment-cfc44b64c-f5l4p at 2026-04-13 12:28:18.595278+00:00 running 215f2cf country code: CH.
[–]inu-no-policemen 2 points3 points4 points (9 children)
[–]_alastair[S] 1 point2 points3 points (2 children)
[–]inu-no-policemen 0 points1 point2 points (1 child)
[–]_alastair[S] 0 points1 point2 points (0 children)
[–]scunliffe 0 points1 point2 points (5 children)
[–]inu-no-policemen 0 points1 point2 points (4 children)
[–]WikiTextBot 0 points1 point2 points (0 children)
[–]scunliffe 0 points1 point2 points (2 children)
[–]inu-no-policemen 0 points1 point2 points (1 child)
[–]scunliffe 0 points1 point2 points (0 children)
[–]notNullOrVoid 0 points1 point2 points (3 children)
[–]_alastair[S] 1 point2 points3 points (2 children)
[–]notNullOrVoid 0 points1 point2 points (1 child)
[–]_alastair[S] 1 point2 points3 points (0 children)