04-lab (Danny, Geoff, Megan)#24
04-lab (Danny, Geoff, Megan)#24dbecker4130 wants to merge 79 commits intocodefellows-seattle-javascript-401d12:masterfrom
Conversation
initial setup complete
helper and constructor skeleton complete
loading initial metadata
Needed to find the offset to the colors by checking the first int of the dib header for the size of the dib header. Colors immediately follow.
Added color table parsing
parsing the pixel array
Constructor now accepts a buffer as a param.
Moved parse code to the constructor
We now store the buffer as a property in our bitmaps. When you save a bitmap, it writes this buffer back to the supplied filename. NOTE: We currently have arrays for colors and pixels, but changes to those arrays will not alter the underlying buffer. We need to change our implementation to deal with this.
Implemented save method in the helper
The constructor method was not ideal, because by creating color and pixel arrays as properties, we were duplicating that data in memory. Not only that, but it would increase the complexity of the save operation to the point where our helper would have to be a bit smarter. The goal is to keep all the logic in the bitmap constructor file, and use the buffer directly inside.
Moved buffer access into getter methods
I added a bunch of notes on how to implement the methods.
I was missing " = function" in my prototype method declarations.
Update git ignore
Setter stubs
test file started
Test cases and TODOs
More or less using the same logic that we have to read pixels.
I used an external tool to rotate the image and save it to this file. The goal is for our transform to be able to match what my image editor produced. NOTE: Adding this to git, because it is a necessary test asset.
Needed to check for non-array param, and arrays with bunk pixel values.
Set pixel array error checks
Constructor test d
For #transform
Needed to get up to date with master.
grayscale transform test added and passes test
adds set color array and tests
Test transforms 1
Added expect().within()
Test that bitmap.transform() returns bitmap
Transform stripes
Also added a test for new Bitmap() without a buf param.
Bitmap error checks
added readme file
bnates
left a comment
There was a problem hiding this comment.
Great job on this project. There's quite a few comment blocks that should be removed from the master branch (these should be contained on development branches) along with, generally, too much code - you'll get better at condensing coding efforts as we continue to work with frameworks and the concepts of modularity so keep this in mind as we push forward in the course
| gulp.watch(['**/*.js', '!node_modules'], ['lint', 'task']); | ||
| }); | ||
|
|
||
| gulp.task('default', ['dev']); |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon gulpfile.js looks good!
| console.log('done saving data:', data); | ||
| }); | ||
|
|
||
| } |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon too much going on in your index.js file - in future iterations (or projects), you'll want to keep the index file reserved for handling the starting/stopping of your application, not the internal logic
| if(err) return callback(err); | ||
| callback(null, data); | ||
| }); | ||
| }; |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon bitmap file helper module looks good
| var bm = new Bitmap(data); | ||
| //TODO: Possibly store filepath in the bm object, or pass as | ||
| // constructor param. | ||
| callback(null, bm); |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon great use of the (err, result) callback pattern along with passing a null value as the first parameter
| Bitmap.prototype.getHeight = function() { | ||
| return this.buf.readUInt32LE(22); | ||
| }; | ||
| Bitmap.prototype.getNumColors = function() { |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon might be best to have these properties as part of the constructor and not on the prototype - odds are, there's no need to call these methods as the metadata should be accessible at all points on every instantiation of a new bitmap
| return this; //To chain transforms | ||
| }; | ||
|
|
||
| module.exports = exports = {}; |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon no need for this, you should only be exporting the constructor, it's prototype methods will be available after instantiation
ex: module.exports = Bitmap and then instantiate as needed in any other file
| pixels[i] = 0; // setting every other pixel to black, offset by one | ||
| } | ||
| bitmap.setPixelArray(pixels); | ||
| }; |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon transform module looks good but doesn't really meet the criteria of following the "constructor pattern" - I'd name this file something different
| ```sh | ||
| $ cd 04-bitmap-transformer | ||
| $ npm install -D chai gulp gulp-eslint gulp-mocha | ||
| ``` |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon README.md looks good
| }); | ||
| }); | ||
|
|
||
| }); |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon tests all look good with the exception of too much internal logic - we'll be writing tons of tests this week (and next) and will be working with some concepts to help remove logic, that should itself be tested, outside of the test environment
| console.log(' src_file: bitmap file to load to be transformed'); | ||
| console.log(' dst_file: where to write the transformed bitmap'); | ||
| console.log(' transforms: Series of transforms to perform, sepearated by spaces'); | ||
| } |
There was a problem hiding this comment.
@dbecker4130 @geoffsimons @meganreardon good printUsage function for UX
Bitmap Transformer assignment complete.
See README