drawimage

Combobox draw image on selected

天涯浪子 提交于 2019-11-28 14:49:50
I try to draw an image from a image list in a combobox when the item is selected. I am able to draw the image, but when the onSelctedIndexChanged event finish, i lost my image. My combobox already have the DrawMode.OwnerDrawFixed I have a ListImage control named ImageList with 10 pictures. For my short example i just need to draw in my combobox the image at position 1 of my ImageList, it's the reason why i get this.ImageList.Draw(g, 0, 0, 1 ); protected override void OnSelectedIndexChanged(EventArgs e) { base.OnSelectedIndexChanged(e); if (this.SelectedIndex > -1) { var g = this.CreateGraphics

G.drawimage draws with incorrect size

ⅰ亾dé卋堺 提交于 2019-11-28 14:38:51
Im creating a big bitmap which contains some smaller images from files. The images have both a size of 250px, but one of them gets smaller and the other bigger than 250px. I'm just using the basic g.drawimage method, so I don't get what I do wrong. string[] imagePaths = Directory.GetFiles(@"C:\Users\admin\Desktop\Images"); ArrayList images = new ArrayList(); foreach (var item in imagePaths) images.Add(new Bitmap(item, true)); Bitmap list = new Bitmap(840, 1188); Graphics g = Graphics.FromImage(list); int size = 0; for (int i = 0; i < images.Count; i++) { g.DrawImage((Bitmap)images[i], new

canvas drawImage doesn't draw images the first time

谁都会走 提交于 2019-11-28 13:39:12
I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical game-loop setup involving: init() function that initializes objects to be used the playfield, randomizing some start x/y positions and similar setup tasks draw() function that draws all the game objects, including some simple canvas shapes and a few images setInterval to call draw every 25 milliseconds While getting this project started, I had the setInterval call at the end of the init() function, so it'd just start drawing and animating as soon as you loaded the page, and everything worked fine. Now that I'm

Canvas: drawImage not drawing image to canvas

青春壹個敷衍的年華 提交于 2019-11-28 12:45:02
问题 I'm using canvas for a game. I have a Sprite object which draws itself to the canvas, in the Sprite class I create the Image member along with it's src attribute when i create the object. Here's the code that's not working: Sprite.prototype.draw = function(Context){ this.Image.onLoad = function(){ Context.drawImage(this.getImage(),this.getX(),this.getY()); }; }; In the objects constructor i pass in a string param which is the file path to the Image - this is being stored correctly. I have a

Fabric.js - problem with drawing multiple images zindex

℡╲_俬逩灬. 提交于 2019-11-28 11:31:56
I'm using this script: var canvas = new fabric.Canvas('game_canvas', { selection: false }); fabric.Image.fromURL('images/bg.jpg', function(img) { img.set('left', 1024/2).set('top', 600/2).set('zindex', 0); canvas.add(img); }); fabric.Image.fromURL('images/panel-2-bg-l-r.png', function(img) { img.set('left', 262/2).set('top', (390/2)+110).set('zindex', 1); canvas.add(img); }); fabric.Image.fromURL('images/player-board.png', function(img) { img.set('left', 254/2).set('top', (122/2)).set('zindex', 2); canvas.add(img); }); fabric.Image.fromURL('images/player-board-top-red.png', function(img) { img

Drawing PNG to a canvas element — not showing transparency

巧了我就是萌 提交于 2019-11-28 09:38:59
I'm trying to use drawImage to draw a semi-transparent PNG on a canvas element. However, it draws the image as completely opaque. When I look at the resource that's being loaded and load the actual PNG in the browser, it shows the transparency, but when I draw it on the canvas, it does not. Any ideas? Here's the code: drawing = new Image() drawing.src = "draw.png" context.drawImage(drawing,0,0); Menno Bieringa Don't forget to add an event listener to the image's load event. Image loading is something that happens in the background, so when the JavaScript interpreter gets to the canvas

Uncaught Error: INDEX_SIZE_ERR

Deadly 提交于 2019-11-28 07:01:04
I am drawing on a canvas with the following line: ctx.drawImage(compositeImage, 0, 0, image.width, image.height, i, j, scaledCompositeImageWidth, scaledCompositeImageHeight); This code has executed error free on Safari, Chrome, Firefox (and even IE using google's excanvas library). However, a recent update to Chrome now throws the following error: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1 This code often positions part or all of the drawn image OFF the canvas, anyone got any idea what's going on here? Is compositeImage pointing at a valid (fully loaded) image? I've seen this exception

HTML5 canvas drawImage with at an angle

梦想的初衷 提交于 2019-11-28 05:47:24
I am experimenting with animation in <canvas> and can't work out how to draw an image at an angle. The desired effect is a few images drawn as usual, with one image rotating slowly. (This image is not at the centre of the screen, if that makes any difference). You need to modify the transformation matrix before drawing the image that you want rotated. Assume image points to an HTMLImageElement object. var x = canvas.width / 2; var y = canvas.height / 2; var width = image.width; var height = image.height; context.translate(x, y); context.rotate(angleInRadians); context.drawImage(image, -width /

G.drawimage draws with incorrect size

瘦欲@ 提交于 2019-11-27 19:38:32
问题 Im creating a big bitmap which contains some smaller images from files. The images have both a size of 250px, but one of them gets smaller and the other bigger than 250px. I'm just using the basic g.drawimage method, so I don't get what I do wrong. string[] imagePaths = Directory.GetFiles(@"C:\Users\admin\Desktop\Images"); ArrayList images = new ArrayList(); foreach (var item in imagePaths) images.Add(new Bitmap(item, true)); Bitmap list = new Bitmap(840, 1188); Graphics g = Graphics

JavaScript Failed to execute 'drawImage'

删除回忆录丶 提交于 2019-11-27 14:25:52
问题 Ok so I'm creating a game with JavaScript Canvas Elements and such. I've been able to load in TONS of Images, but on a select few, JavaScript replies with Errors such as Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided. Which makes NO SENSE at all, because the same code works in other places!?! Here is an example I have in my code: board.drawImage(document.getElementById("player_explode"), this.x, this.y