Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:51:56+00:00 2026-06-09T09:51:56+00:00

I have drawn 3 images on a canvas and blended them using this solution,

  • 0

I have drawn 3 images on a canvas and blended them using this solution, everything is working well and I am very happy but I would like to apply an opacity to the pixels on the canvas – something similar to this method – http://www.patrick-wied.at/blog/how-to-create-transparency-in-images-with-html5canvas which has been tried and didn’t work.

Once the canvas pixels have opacity applied I then need to add in another image layered underneath the translucent pixels and export the whole thing as a png.

Here is my code for the images and blending

  var img1 = document.getElementById("userImage")

  var img2 = document.getElementById('right_cheekImage');
  var img3 = document.getElementById('left_cheekImage');
  var img4 = document.getElementById('left_eyeImage');

  var canvas = document.getElementById("canvasID");
  var context = canvas.getContext("2d");

  var width = img1.width;
  var height = img1.height;
  canvas.width = 644;
  canvas.height = 490;

  context.drawImage(img1,0, 0, width, height);
  var image1 = context.getImageData(0, 0, width, height);
  var imageData1 = image1.data;
  context.drawImage(img2, img2.left, img2.top);
  context.drawImage(img3, img3.left, img3.top);
  context.drawImage(img4, img4.left, img4.top);

  var image2 = context.getImageData(0, 0, width, height);
  var imageData2 = image2.data;

  while (pixels--) {
        imageData1[pixels] = imageData1[pixels] * blendOne + imageData2[pixels] * blendTwo;
  }
  //apply opacity to pixels currently on the canvas
  for(var i=3; i < length; i+=4){
        imageData1[i] = 50;
  }

  image1.data = imageData1;

  //put in userimage again but under others
  context.drawImage(img1,newOffset, topPos, width, height);

  context.putImageData(image1, 0, 0);

As you can see I’ve added in some code to add opacity to the pixels currently on the canvas but it’s not working.

If anyone can shed some light on this that would be amazing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:51:57+00:00Added an answer on June 9, 2026 at 9:51 am

    Just a quick fiddle to show you how to merge different canvasses.

    A common technique is to do image manipulation in one canvas and then later draw this invisible canvas into the one you are actually going to display.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical
Using javascript, I've drawn several polygon images on my canvas. I'd like to, based
I have an HTML5 canvas image where I've drawn some points and I want
I've got a canvas drawn (I have to keep the canvas, it's doing other
It seems google images search is using canvas to draw images and original images
I have problem to draw line on scaled and transformed image on canvas, well
I'm working on a simple JavaScript based game using the canvas tag. As part
I have drawn an image on a Composite using the following code imageCanvas =
I am working with small application for display bubbles images on android screen.I have
This program will have an infinite canvas (ie as long as the user scrolls,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.