Does canvas support PNG alpha? Im having some issues with a few PNGs that I've added to the canvas. The edges of the images are black and jagged as if no alpha channel exists or is being recognized.
PNG Transparency on Canvas
12.3k Views Asked by Rigil At
2
There are 2 best solutions below
0
adrield
On
Use clearRect() or fillRect() before redrawing the PNG image, if you are doing it in a requestAnimationFrame or setInterval loop.
I stumbled upon this question as I had a similar problem, but my image was already at 24-bit. Had a requestAnimationFrame loop redrawing the PNG image to the canvas and (as you said) as they overlapped, the result was this "burned" edges where it should have the alpha "fade-out" transparency.
Simply by cleaning the area before calling drawImage, you can prevent that image to be rendered over itself.
Related Questions in CANVAS
- http://sigmajs.org/ les mis tutorial - why are my canvases 0 height?
- How to know whether the mousedown event is occured on where we want in canvas?
- Scrollbar for Message Widget in Tkinter
- Resize function canvas loaded on shrinked browser and expanded
- Canvas - Rotate line
- html5 canvas circle palette
- How can I make a button who draws a line
- The canvas.drawpath not work for me
- Touch listener on path android canvas
- html5 canvas with image: save original imagesize
- On iOS, how do I resize a very large image on the client side in a web app?
- Easeljs snap to grid
- a border where you can not go through (canvas game)
- How can I implement a zoom function in a 2D canvas?
- THREE.JS MakeTextSprite properties
Related Questions in PNG
- Understanding the function of this particular 9 patch image
- How can I convert PNG to GIF keeping the transparency?
- Conversion from MathML equation to flash?
- Overlay image in ts file
- gnuplot png white on black
- Using R to convert png files to animation
- PNG transparent backgrounds appearing black when using Android Studio
- Post png image to pngcrush with Ruby
- Skip bytes in ByteArray Java
- Random Line Appearing on Moving Texture Node
- How do I grep GZ files to extract PNG files?
- png uncompressed by CGContextDrawImage is different from orign png image in xcode
- Why the first byte of .png file is 0x89?
- worklight server preview wont show png resources anymore after configuring it to serve svg
- Android: Embedding a compressed image inside a PDF document
Related Questions in TRANSPARENCY
- How can I add a transparent tkinter image in Python 3.3.2?
- Transparent RichTextBox with Graphic not showing Text
- How to remove UINavigationBar transparency in iOS8?
- Fluid login form with different transparency of background holder
- Set mesh transparency Meshlab
- Android OpenGL Transparent Texture Draws Black
- Is it possible to have a element transparent and see through his parent opaque background
- In CSS3, using `transparency` with `gradient` doesn't work?
- OpenLayers3: best way to display multiple WMS layers in trasparency
- Windows Form Application - Transparent PictureBox Image overwrites Form Transparency
- WS_EX_TOOLWINDOW with TransparencyKey causes Win32Exception
- ImageMagick: How to make both black and white transparent?
- Clear Transparent Background for QWidget
- How can I apply a fade-out-text effect with a transparent-to-white gradient?
- Trouble with Transparent Background in scene created with Three.js Editor
Related Questions in ALPHA
- javascript strokeRect opacity not setting to 1
- how to infer alpha value from pair of opaque images
- png uncompressed by CGContextDrawImage is different from orign png image in xcode
- How can I put a device-independent bitmap into the Windows clipboard using just direct WinAPI? (No MFC or other wrappers)
- Animation of setAlpha for UILabel not working
- Add a semi-transparent layer to UIImage using Core Graphics
- SWIFT iOS --- UIApplication.sharedApplication() functions reseting all labels/alphas/hidden properties etc
- Adjust alpha of UIColor
- Sequence Action With EnumerateChildNodeWithName
- How to deal with etc1 alpha channel
- Swift animatewithDuration() instantly completes
- React Native clickable Image with Alpha
- Swift 3 (SpriteKit): Changing the alpha value of the parent which affects all children
- ggplot scale alpha continuous fill color
- Reverse overplotting alpha value in ggplot2
Related Questions in COLOR-CHANNEL
- Display only one channel in a html img as greyvalue image
- Convert Color32 array to byte array to send over network
- GStreamer - swap color channels of RGB-video
- Using PIL to adjust color saturation of list of images. I receive no errors but the output does not reflect my changes
- cv2.imwrite changes color when saving from np.array to JPG
- Normalizing color channels of and image by intensity values, OpenCV
- Extract hue channel from HSV image in Pillow
- Android Edit Bitmap Channels
- PNG Transparency on Canvas
- Converting RGBA to YUV422 format using c++ - not getting proper output
- PNG alpha channel on UIButton (iPad)
- Why applying the same channel thrice results in a black and white image?
- Converting TYPE_INT_RGB to TYPE_BYTE_GRAY image creates wrong result
- Hiding certain channel of an image with C#
- Remove filter on image
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If you put a 24-bit PNG with alpha on the canvas it understands it.
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Using_images
Maybe your PNGs are not clean, i.e. have non-transparent regions at the borders?