Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To continue from the comments:</p> <p>The approach you are taking doesn't seem a very good one at all. Fixing the 2 things from the comments will still produce other issues. To think of 1 it is what happens if user drags 2 lines at the same place? Will the image be blurred twice on that spot? It might but I can assure you it will lose its functionality.</p> <p>To look things a bit more general on what you are trying to do: You want the user to be able to select parts of the image to be blurred which is exactly what you should do. This results in you needing another buffer that will store only that data, either the pixel is blurry or not (can also store the strength of the blur). So in general I would suggest creating a FBO (frame buffer object) with attached texture. Then move the drawing code you already have (with points) to draw a specific color on that buffer. Now each time the FBO changes you need to redraw your whole main buffer using the 2 textures (original and FBO's) drawing original where FBO's texture is empty and blurred image where the texture is full. This procedure would also suggest that you rather blur the whole image in load time and use 3 textures (original, blur, canvas).</p> <p>The FBO approach is very flexible and in mentioned case you can use it for much more then blur locations. You can have multiple effects and their strength using different color channels and is independent to what resources you are using in your main buffer. On the other hand it might get a bit hard to implement: FBO size will have to be a power of 2 and you need to use just a certain part of it (not a problem), applying its texture to the main buffer will force you to compute a new texture coordinate buffer (medium math problem), if you apply some zooming and moving things can get very hard (big problem). Guessing from your case you can do this much easier.</p> <p>Instead of drawing some color to the FBO you can just use some other buffer that can be attached to your main frame buffer: Draw only to depth buffer or rather stencil buffer (little setup) since you probably don't use them at all. Now for the grand finally you probably don't even use the alpha channel on your buffer:</p> <ul> <li>when a new image is set create original and blurred texture, clear the buffer to zero for all channels, disable blend and use color mask to RGB only (<code>glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE)</code>) and draw the original as you did before.</li> <li>On touches moved disable blend, enable alpha channel only and use a color with alpha value <code>1.0</code> and reuse the drawing code you already have except you should only draw color, not a blurred texture</li> <li>On refresh (after touches moved) enable RGB channels only, enable blend and use <code>glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA)</code> and draw a fullscreen blurred texture.</li> </ul> <p>All done, just a small note here: If you will at some point want an image snapshot and you will use <code>glReadPixels</code> you need to understand that your alpha channel is a mess and you need to skip it when creating a CGImage from those data.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload