drawimage

drawImage using toDataURL of an html5 canvas

大憨熊 提交于 2019-12-22 11:37:32
问题 What I am doing now is the following: I am storing the state of a canvas using the toDataURL method and I am also trying to draw it on a canvas using the drawImage method. Here is a snippet: var lastState = states[10]; //states is an array that saves all the toDataURL of the canvas var permCtx = canvas.getContext('2d'); var img = new Image(); img.onload=function(){ permCtx.drawImage(img,0,0); } img.src=lastState; I am getting the following error in the console: 414 (Request-URI Too Large) Is

How to display a PictureBox from behind code in C#

 ̄綄美尐妖づ 提交于 2019-12-21 17:38:06
问题 I know my question sounds basic, but i searched all over the place and found nothing.. this is my code : public MainWindow() { InitializeComponent(); Map newMap = new Map(); newMap.setMapStrategy(new SmallMapStrategy()); newMap.createMap(); System.Windows.Forms.PictureBox pictureBox1 = new System.Windows.Forms.PictureBox(); pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(newMap.grid[3].afficher); } this is the afficher function : public override void afficher(object sender,

Canvas drawImage scaling

牧云@^-^@ 提交于 2019-12-18 10:37:41
问题 I'm trying to scale an image proportionately to the canvas. I'm able to scale it with fixed width and height as so: context.drawImage(imageObj, 0, 0, 100, 100) But I only want to resize the width and have the height resize proportionately. Something like the following: context.drawImage(imageObj, 0, 0, 100, auto) I've looked everywhere I can think of and haven't seen if this is possible. 回答1: context.drawImage(imageObj, 0, 0, 100, 100 * imageObj.height / imageObj.width) 回答2: solution of

How to draw photo with correct orientation in canvas after capture photo by using input[type='file'] in mobile web browser?

本秂侑毒 提交于 2019-12-17 17:28:25
问题 I am making a simple web app in mobile which allow visitor to capture photo by using html5 input[type=file] element. Then I will display it on the web for preview, and then visitor can choose to upload the photo to my server for other purpose(ie: upload to FB) I find a problem on the orientation of photo when I take photo using my iPhone and hold vertically.The photo is in a correct orientation in tag. However, when I try to draw it into canvas by using drawImage() method, it is drawn 90

Canvas Draw Image issue on firefox, works well in chrome

爷,独闯天下 提交于 2019-12-17 14:56:10
问题 I will assume this is some sort of compatibility issue. Everything works perfectly in chrome, but in firefox the <canvas> simply doesn't draw anything. function drawStage(stageNum) { var cap = canvasArray.length; //keeps the canvasElements var i; var stageImages = images["stage" + stageNum]; var stageDimensions = imageDimensions["stage" + stageNum]; //console.log("Cap is: " + cap); for (i = 0; i < cap; i++) { var canvas = document.getElementById(canvasArray[i]); var canvasContext = canvas

How can I draw an image from the HTML5 File API on Canvas?

最后都变了- 提交于 2019-12-17 08:24:11
问题 I would like to draw an image opened with the HTML5 File API on a canvas. In the handleFiles(e) method, I can access the File with e.target.files[0] but I can't draw that image directly using drawImage . How do I draw an image from the File API on HTML5 canvas? Here is the code I have used: <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script> window.onload = function() { var input = document.getElementById('input'); input.addEventListener('change', handleFiles); } function

How can I draw an image from the HTML5 File API on Canvas?

夙愿已清 提交于 2019-12-17 08:24:07
问题 I would like to draw an image opened with the HTML5 File API on a canvas. In the handleFiles(e) method, I can access the File with e.target.files[0] but I can't draw that image directly using drawImage . How do I draw an image from the File API on HTML5 canvas? Here is the code I have used: <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script> window.onload = function() { var input = document.getElementById('input'); input.addEventListener('change', handleFiles); } function

Using Graphics.DrawImage() to Draw Image with Transparency/Alpha Channel

你说的曾经没有我的故事 提交于 2019-12-17 06:48:13
问题 I'm copying an image. (My actual code is resizing the image but that's not relevant to my question.) My code looks something like this. Image src = ... using (Image dest = new Bitmap(width, height)) { Graphics graph = Graphics.FromImage(dest); graph.InterpolationMode = InterpolationMode.HighQualityBicubic; graph.DrawImage(src, 0, 0, width, height); dest.Save(filename, saveFormat); } This seems to work great unless src is loaded from an image with transparencies (such as GIF) or an alpha

Making an image fade in and fade out? [closed]

假装没事ソ 提交于 2019-12-14 04:14:30
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . How would I go about making an image fade in and then out? I know an easy way to accomplish this is to just make several images with different opacities. 回答1: Use an AlphaComposite when painting the image: import java.awt.AlphaComposite; import java.awt.Graphics; import java.awt.Graphics2D; import

Canvas drawImage size error

六月ゝ 毕业季﹏ 提交于 2019-12-14 03:57:46
问题 I’m using two html canvas, the fronendCanvas is visible to the users and is part of the html DOM tree and is set to have 100% of the window width and height, the backendCanvas is created on the javascript code and is used to contain the huge diagram that I need to draw. /** FrontendCanvas */ // HTML <canvas id="canvas"></canvas> // JavaScript frontCanvas.width = window.innerWidth; frontCanvas.height = window.innerHeight; // CSS #canvas { display: block; background-color: #dddddd; } /**