Skip to content

DM-10369: client side mask color change #364

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

Merged
merged 2 commits into from
Apr 27, 2017
Merged

Conversation

robyww
Copy link
Contributor

@robyww robyww commented Apr 27, 2017

Changes:

  • Processing image on the client side to set mask color
  • Add image processing framework that can be used in future of color bar changing
  • Processed images can be added to store as data png
  • include new functions in WebUtil.js: loadImage and requestIdleFrame
  • small clean up of PlotViewUtil

Code to pay attention to:

  • ImageViewerLayout.jsx - small changes but it definea function that modifies image
  • ImageRender.jsx - Image drawing react component - mostly wrapper around CanvasTileDrawer
  • ImageProcessor.js - image retrieval and processing framework
  • CanvasTileDrawer.js - Does the actually canvas rendering and managing cached images

To Test

  • Use a LSST image that has mask.
  • Overlay the mask
  • change the mask color - affects will be immediate
  • talk to @robyww is you need the fits files.

  - Processing image on the client side to set mask color
  - Add image processing framework that can be used in future of colobar changing
  - Processed images can be added to store as data png
  - include new functons in WebUtil: loadImage and requestIdleFrame
  - small clean up of PlotViewUtil
@robyww robyww self-assigned this Apr 27, 2017
@robyww robyww requested a review from cwang2016 April 27, 2017 16:26
var num = parseInt(color, 16);
return [num >> 16, num >> 8 & 255, num & 255];
const num = parseInt(color[0]==='#' ? color.substr(1) : color, 16);
return [num >> 16, num >> 8 & 255, num & 255];
}

Copy link
Contributor

Choose a reason for hiding this comment

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

you may also call function getRGBA() in Color.js which handles the color string like '#...', 'rgb(...)', 'rgba(...)' or a pure color name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will use that.

const {data}= imageData;
const len= data.length;
for(let i= 0; i<len; i+=4) {
if (data[i] || data[i+1] || data[i+2]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean if data[i], data[i+1] and data[i+2] are all zero, then the condition for 'if' is 'false'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for making me really think about this. You found a bug, if the user every turns it black then the mask gets stuck at that color.

It should be
if (data[i] || data[i+1] || data[i+2] || data[i+3]) {

However, now that I think about it, in the mask case the only element in the array that matters for detecting if I need to set the color is data[i+3] so I can optimize it to

if (data[i+3]) {

In the array data[i], data[i+1], data[i+2] is a RGB and data[i+3] is opacity. The images from the server set all 4 to zero because we want full transparency (no mask bit) and data[i+3] to 255 if there is a mask bit. So I can just look at the opacity index in the if, which should be more efficient. The image arrays are big so efficiency matters.

Thank you!

@cwang2016
Copy link
Contributor

Review completes. The mask color change works well.

@robyww robyww merged commit 6b3ff9d into dev Apr 27, 2017
@robyww robyww deleted the dm-10369-mask-color-change branch April 27, 2017 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants