Skip to content

Will Shiv and Anna #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
de6d887
lintrc and gitignore added
Feb 16, 2017
9f99589
project skeleton laid out
Feb 16, 2017
3a85f2f
all logic sorted out, we chillin
Feb 17, 2017
7577ec7
Merge pull request #1 from shivprogrammer/shivbitmap
shivprogrammer Feb 17, 2017
b531d8b
program can now export img.
Feb 17, 2017
cb06fa4
now turning picture black
Feb 17, 2017
8f010ad
invert is almost done
Feb 18, 2017
d862271
Merge pull request #2 from shivprogrammer/will
shivprogrammer Feb 18, 2017
59a292e
iteration fixes
Feb 18, 2017
3d4758b
Merge pull request #3 from shivprogrammer/shivbitmap
shivprogrammer Feb 18, 2017
642b1cb
invert is working
Feb 18, 2017
a063046
Merge branch 'master' into will
shivprogrammer Feb 18, 2017
65f91d3
Merge pull request #4 from shivprogrammer/will
Feb 18, 2017
363ceef
code reduced with buffer.fill()
Feb 18, 2017
a0235b1
Merge pull request #5 from shivprogrammer/anna
Feb 18, 2017
3569dc5
inverted bitmap writes to file
Feb 18, 2017
94c7a74
Merge pull request #6 from shivprogrammer/anna
Feb 18, 2017
83f8663
black and inverted works
Feb 18, 2017
34df57d
Merge pull request #7 from shivprogrammer/anna
Feb 18, 2017
5cede5f
creating new buffers for each transform
Feb 18, 2017
cd2e87f
Merge pull request #8 from shivprogrammer/anna
Feb 18, 2017
4119c76
done for now. a few simple transforms, will think about more complex …
Feb 18, 2017
f600bec
Merge pull request #9 from shivprogrammer/anna
Feb 18, 2017
1d5c776
reset
Feb 19, 2017
64642e3
Merge pull request #10 from shivprogrammer/anna
Feb 19, 2017
5dcc235
now it works
Feb 19, 2017
a3ea6cc
Merge pull request #11 from shivprogrammer/anna
Feb 19, 2017
209510d
all tests added and passing
Feb 20, 2017
ec40b88
Merge pull request #12 from shivprogrammer/shivtests
shivprogrammer Feb 20, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul .eslintrc looks good

117 changes: 117 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Created by https://www.gitignore.io/api/node,vim,osx,macos,linux

*node_modules

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity



### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### macOS ###
# Icon must end with two \r
# Thumbnails
# Files that might appear in the root of a volume
# Directories potentially created on remote AFP share


### Linux ###

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# End of https://www.gitignore.io/api/node,vim,osx,macos,linux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul .gitignore looks good

21 changes: 21 additions & 0 deletions bitmap-annashivwill/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul duplicate eslintrc???

117 changes: 117 additions & 0 deletions bitmap-annashivwill/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Created by https://www.gitignore.io/api/node,vim,osx,macos,linux

*node_modules

### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity



### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### macOS ###
# Icon must end with two \r
# Thumbnails
# Files that might appear in the root of a volume
# Directories potentially created on remote AFP share


### Linux ###

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# End of https://www.gitignore.io/api/node,vim,osx,macos,linux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul same deal here - duplicate .gitignore???

41 changes: 41 additions & 0 deletions bitmap-annashivwill/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) Lab 04: Bitmap Transformer
===

## To Submit this Assignment
* have team leader fork this repository
* have team leader add team members as collaborators to the team fork
* team members should clone team fork
* write all of your code in a directory name `bitmap-` + `<team name>` **e.g.** `bitmap-weasels`
* submit a pull request to this repository when done
* each person will submit a link to their own PR in canvas
* each person write a question and observation on canvas

#### Rubric:
* **tests:** 3pts
* **gulpfile/package.json:** 2pts
* **read bitmap meta data:** 5pts
* **successfully apply transforms:** 5pts
* **project design and organization:** 5pts

## Description

For this assignment you will be building a bitmap (`.bmp`) reader and transformer. It will read a bitmap in from disk, run one or more color transforms on the bitmap and then write it out to a new file. This project will require the use of node buffers in order to manipulate binary data. Your project should include tests, as well as a `gulpfile.js`, `package.json`, `.eslintrc`, `README.md`, and a `.gitignore`. Make sure to run all your code through eslint. The process will look something like this:

1. open the original bitmap file using fs and read it into a buffer
2. convert the buffer header data into a Javascript Object (using constructors)
3. run a transform on the buffer directly
4. write the buffer to a new file

The wikipedia article found here [Bitmap Specification](https://en.wikipedia.org/wiki/BMP_file_format) describes the byte specification of a "windows bitmap file." We'll be working with the simplest version, meaning no compression.

* your project should have three ***(or more)*** transforms
* invert the colors (***hint:*** subtract every color value from the max color value which is 255),
* grayscale the colors (***hint:*** multiply each color value by a constant, just make sure your values don't go over 255)
* (red|green|blue)scale the colors (***hint:*** same as above but only multiply one of the colors)

## Bonus:

* ability to handle various sized bitmap
* ability to handle LE and BE computers with a single if statement
* utilizes a command line interface (CLI)
* CLI can select the transforms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul documentation outlined in your README is excellent - nice job on this

Binary file added bitmap-annashivwill/img/black.bmp
Binary file not shown.
Binary file added bitmap-annashivwill/img/grey.bmp
Binary file not shown.
Binary file added bitmap-annashivwill/img/inverted.bmp
Binary file not shown.
Binary file added bitmap-annashivwill/img/palette-bitmap.bmp
Binary file not shown.
Binary file added bitmap-annashivwill/img/red.bmp
Binary file not shown.
6 changes: 6 additions & 0 deletions bitmap-annashivwill/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

const maps = require(`${__dirname}/model/read-write.js`);
const transforms = require(`${__dirname}/lib/transforms.js`);

maps.readWrite();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul excellent job keeping your index file clean - no need to use ${__dirname} in your require paths - relative file paths are fine for this

10 changes: 10 additions & 0 deletions bitmap-annashivwill/lib/file-reader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const fs = require('fs');

const fileReader = module.exports = function(file, callback) {
fs.readFile(file, function(err, data) {
if (err) return callback(err);
return callback(null, data);
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul awesome job creating a file-reader module for reusability

41 changes: 41 additions & 0 deletions bitmap-annashivwill/lib/transforms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

const fs = require('fs');
const image = require(`${__dirname}/../index.js`);

module.exports = exports = {};

exports.turnBlack = function(bitmap) {
const blackBuf = new Buffer(bitmap);
return blackBuf.fill('00', 54, 1078);
// console.log(blackBuf);
};

exports.invert = function(bitmap) {
const invertBuf = new Buffer(bitmap);
for (var i = 54; i < 1078; i++) {
invertBuf.fill(255-bitmap[i], i, i+1);
};
// console.log(invertBuf.toString('hex').slice(54,1078));
return invertBuf;
};

exports.redScale = function(bitmap) {
const redBuf = new Buffer(bitmap);
for(var i = 56; i < 1078; i += 4) {
redBuf.fill(255, i, i+1);
};
// console.log(redBuf.toString('hex').slice(54,1078));
return redBuf;
};

exports.greyScale = function(bitmap) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@William-Skelton @shivprogrammer @annaul the transform methods in this file are really good - that said, they may be better served as prototype methods built on to the constructor - the constructor could hold the raw buffer and the methods could then interact directly with them

all that said, this is still really clean and good

const greyBuf = new Buffer(bitmap);
for(var i = 54; i < 1078; i += 4) {
greyBuf.fill(greyBuf[i+1], i, i+1);
greyBuf.fill(greyBuf[i+1], i+1, i+2);
greyBuf.fill(greyBuf[i+1], i+2, i+3);
};
// console.log(greyBuf.toString('hex').slice(54,1078));
return greyBuf;
};
Loading