Skip to content

Instantly share code, notes, and snippets.

@AndrewRayCode
Created November 22, 2015 05:01
Show Gist options
  • Select an option

  • Save AndrewRayCode/4456d69f2582d28df7f5 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewRayCode/4456d69f2582d28df7f5 to your computer and use it in GitHub Desktop.
function copyUIntToImageData( uint, imageData ) {
for( let i = 0; i < uint.length; i += 4 ) {
let index = uint.length - i; // flip how data is read
imageData.data[ index ] = uint[ i ]; //red
imageData.data[ index + 1 ] = uint[ i + 1 ]; //green
imageData.data[ index + 2 ] = uint[ i + 2 ]; //blue
imageData.data[ index + 3 ] = uint[ i + 3 ]; //alpha
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment