drawimage

BufferedImage in JFrame doesnt Show up

烂漫一生 提交于 2019-12-13 18:43:42
问题 trying to get an image to print into a window. Everything runs without errors, and it also works if I replace the drawImage with another graphics class. However, the window is missing the image, and i'm not sure why. Again, the JFrame stuff and Graphics work fine with drawing other graphics, but only doesn't draw the image here. Thanks. import javax.swing.JApplet; import javax.swing.JFrame; import javax.imageio.*; import javax.imageio.stream.*; import java.awt.*; import java.awt.image.*;

setTransform and Scale to fit Canvas for the given image

帅比萌擦擦* 提交于 2019-12-13 03:48:12
问题 I have an image on Canvas. After rendering an image, I rotate the canvas to 90 degrees clockwise and then have to scale to fit the canvas. Scaling an image to fit on canvas Resize image and rotate canvas 90 degrees there is so many solutions available but unfortunately none of them worked for me yet This is what I have right now. width = 300; // after rotation height = 400; // after rotation var scale = width / img.height; // how much to scale the image to fit console.log(scale); canvas.width

HTML5 canvas drawImage not working on first click

徘徊边缘 提交于 2019-12-12 12:13:22
问题 I have a canvas that I am using a javascript function to display text and a couple of images. The issue that I am running into is that the click does perform the function and displays the text, but does not always place the images. If clicked a second time, the images appear. This behavior is consistent in all browsers. The command is not slow, it just fails to display the images the first time. TIA // JavaScript Document function manualsTxt() { var theCanvas = document.getElementById(

Why does drawImage performance differ greatly with larger than 65776 pixel canvas sources

人走茶凉 提交于 2019-12-12 11:02:41
问题 I wrote some test cases on jsperf related to: 1. drawing on an offscreen canvas 2. drawImage to an onscreen canvas I found that performance was much higher if the number of pixels in the source canvas (regardless of dst) was less than ~ 65776 pixels. (I expected this performance limit to be 65536 pixels, if it was going to be anything) Here are my test cases: http://jsperf.com/pixel-count-matters/2 http://jsperf.com/magic-canvas/2 I believe this person is asking a similar question: Why does

Firefox won't draw to canvas on first visit

谁说胖子不能爱 提交于 2019-12-12 05:39:19
问题 I have an issue I'm having a hard time believing... It seems that when I draw to a dynamically created canvas in Firefox it wont render the first time that source is run... It seems to happen the first time the JavaScript in question is run either by modifying the source or visiting the link for the first time. Here are some repro steps: 1) open a brand new instance of Firefox. visit the jsFiddle below. 2) see nothing 3) open a new tab in Firefox. visit the jsFiddle below. 4) see the result

canvas.drawImage blows the cropped imaged out of proportion

北慕城南 提交于 2019-12-11 11:25:41
问题 When rendering the following image (right-click + view image to see full size): of size 4800x320 with html5 canvas.drawImage() and trying to crop a partial 480x320 image from it, the canvas blows the image up. Here is my code: var canvas = document.createElement('canvas'); canvas.setAttribute('id', 'my-canvas'); canvas.style.width = 480; canvas.style.height = 320; canvas.style.display = 'block'; document.body.appendChild(canvas); var img=document.createElement('img'); img.src='http://cdn

How to use getters to return an image in java?

此生再无相见时 提交于 2019-12-11 09:42:06
问题 I have a class which has among its attributes an Image. I made a simple getter to return this image.. public Image getImage() { return image; } Later I try to use this getter in a drawImage() but do not get an image. g.drawImage(c.getImage(), c.getXcord(), c.getYcord(), null, this); As you can see I have other getters for this class (getXcord, getYcord) which work fine, but I can't seem to get the image. Here the class WoodlandCreatures public class WoodlandCreatures extends Animals { public

Canvas clearing issue. Select objects not clearing in Canvasteroids

筅森魡賤 提交于 2019-12-11 07:07:07
问题 I am creating a new asteroids game with html5 canvas. It's been going well up to the point where I have to dynamically draw lasers onto the stage. They don't draw correctly (they should only be 10pixels long) and when you shoot twice over 10 seconds apart the old laser trail shows up. Here's the url because there's more code than I care to put everyone through. http://marccannon.com/canvasteroids/ Ideally the lasers will be 10px long and go away once they're out of life (1sec or 33 frames).

canvas drawimage draw zoomed image

妖精的绣舞 提交于 2019-12-11 05:24:21
问题 I need to set canvas size using code and than drawImage on this canvas. The problem is drawn image is zoomed. code follows - currentImageDIV = $("#cnv").css({ "position" : "relative" ,"height": 400, "width": 800,"top" :"100px" , "border": "1px solid red" }); var c = document.getElementById("cnv"); var ctx = c.getContext("2d"); ctx.imageSmoothingEnabled = false; var img = new Image(); img.src = "/images/sample2.jpg"; img.onload = function () { ctx.drawImage(img, 0, 0); } If I do not set the

Fading a loaded image into Canvas with drawImage

让人想犯罪 __ 提交于 2019-12-11 04:17:18
问题 This question about crossfading images already gave an answer to the crossfading solution in Canvas. I am trying to do the same thing, only difference is that i am trying to fade images that are loaded on runtime. The images are loaded propperly but no fade is visible. Is this not working because of the loaded images? Thanks. HTML <div id="wrapper"> <canvas id="bg1"></canvas> <canvas id="bg2"></canvas> </div> JS var toggle = true; var canvas = document.getElementById('bg1'); canvas.width = $