pixel-manipulation

Why is setting HTML5's CanvasPixelArray values ridiculously slow and how can I do it faster?

馋奶兔 提交于 2019-12-18 12:54:29
问题 I am trying to do some dynamic visual effects using the HTML 5 canvas' pixel manipulation, but I am running into a problem where setting pixels in the CanvasPixelArray is ridiculously slow. For example if I have code like: imageData = ctx.getImageData(0, 0, 500, 500); for (var i = 0; i < imageData.length; i += 4){ imageData.data[i] = buffer[i]; imageData.data[i + 1] = buffer[i + 1]; imageData.data[i + 2] = buffer[i + 2]; } ctx.putImageData(imageData, 0, 0); Profiling with Chrome reveals, it

Smooth jagged pixels

▼魔方 西西 提交于 2019-12-12 04:41:24
问题 I've created a pinch filter/effect on canvas using the following algorithm: // iterate pixels for (var i = 0; i < originalPixels.data.length; i+= 4) { // calculate a pixel's position, distance, and angle var pixel = new Pixel(affectedPixels, i, origin); // check if the pixel is in the effect area if (pixel.dist < effectRadius) { // initial method (flawed) // iterate original pixels and calculate the new position of the current pixel in the affected pixels if (method.value == "org2aff") { var

Buffered image pixel manipulation

落爺英雄遲暮 提交于 2019-12-02 05:15:35
问题 I have this code: public Image toNegative() { int imageWidth = originalImage.getWidth(); int imageHeight = originalImage.getHeight(); int [] rgb = null; // new int[imageWidth * imageWidth]; originalImage.getRGB(0, 0, imageWidth, imageHeight, rgb, 0,imageWidth); for (int y = 0; y < imageHeight; y++) { for (int x = 0; x < imageWidth; x++) { int index = y * imageWidth + x; int R = (rgb[index] >> 16) & 0xff; //bitwise shifting int G = (rgb[index] >> 8) & 0xff; int B = rgb[index] & 0xff; R = 255 -

How do you simply obtain an array of pixel data from an image?

无人久伴 提交于 2019-12-01 03:11:41
Thank you all for responding. I should have been more specific with my question. I looked at a number of examples, but here is the one from W3 Schools (thank you @Pointy for pointing out that this is not a source one should rely on - no pun intended). http://www.w3schools.com/tags/canvas_getimagedata.asp <!DOCTYPE html> <html> <body> <img id="scream" src="img_the_scream.jpg" alt="The Scream" width="220" height="277"> <canvas id="myCanvas" width="220" height="277" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> document.getElementById(

How do you simply obtain an array of pixel data from an image?

我怕爱的太早我们不能终老 提交于 2019-11-30 23:17:49
问题 Thank you all for responding. I should have been more specific with my question. I looked at a number of examples, but here is the one from W3 Schools (thank you @Pointy for pointing out that this is not a source one should rely on - no pun intended). http://www.w3schools.com/tags/canvas_getimagedata.asp <!DOCTYPE html> <html> <body> <img id="scream" src="img_the_scream.jpg" alt="The Scream" width="220" height="277"> <canvas id="myCanvas" width="220" height="277" style="border:1px solid

Android image sharpening, saturation, hue, brightness, and contrast

拥有回忆 提交于 2019-11-30 10:46:47
I'm trying to create an app that will allow me to adjust the hue, saturation, brightness, contrast, and sharpness of an image by adjusting the seekbars for each of the above fields. like at http://ronbigelow.com/articles/workflow_basic/hue-saturation_tool.jpg I have no idea how to do this and I can't find any tutorials online. Does Android have anything that does this already? Do I have to manipulate the colors of individual pixels? If I have to mess with the pixels, how would I do that? Yes, android has some tools for manipulating colors, some easier than others. The only way to do what you

Android image sharpening, saturation, hue, brightness, and contrast

旧城冷巷雨未停 提交于 2019-11-29 15:37:28
问题 I'm trying to create an app that will allow me to adjust the hue, saturation, brightness, contrast, and sharpness of an image by adjusting the seekbars for each of the above fields. like at http://ronbigelow.com/articles/workflow_basic/hue-saturation_tool.jpg I have no idea how to do this and I can't find any tutorials online. Does Android have anything that does this already? Do I have to manipulate the colors of individual pixels? If I have to mess with the pixels, how would I do that? 回答1: