drawimage

Javascript: drawImage is not taking whole picture

最后都变了- 提交于 2020-01-25 20:52:07
问题 Here's the code: window.onload = function() { var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var img = document.getElementById("scream"); ctx.drawImage(img, 0, 0, img.height, img.width, 0, 0, 100, 100); }; Here's the picture: I set it to get the whole image by setting img.height and img.width. But still I see that no whole picture is there, only part: bottom part is getting cut. How can I get it? Am I entering wrong value? Refer here 回答1: Arguments of function

PDFBox: put two A4 pages on one A3

旧巷老猫 提交于 2020-01-25 20:41:10
问题 I have a pdf document with one or more pages A4 paper. The resulting pdf document should be A3 paper where each page contains two from the first one (odd on the left, even on the right side). I already got it to render the A4 pages into images and the odd pages are successfully placed on the first parts of a new A3 pages but I cannot get the even pages to be placed. public class CreateLandscapePDF { public void renderPDF(File inputFile, String output) { PDDocument docIn = null; PDDocument

PDFBox: put two A4 pages on one A3

孤者浪人 提交于 2020-01-25 20:41:02
问题 I have a pdf document with one or more pages A4 paper. The resulting pdf document should be A3 paper where each page contains two from the first one (odd on the left, even on the right side). I already got it to render the A4 pages into images and the odd pages are successfully placed on the first parts of a new A3 pages but I cannot get the even pages to be placed. public class CreateLandscapePDF { public void renderPDF(File inputFile, String output) { PDDocument docIn = null; PDDocument

HTML5 Canvas: Get Event when drawing is finished

扶醉桌前 提交于 2020-01-19 05:37:59
问题 I'm drawing an image to a canvas element. I then have code that depends on this process to be finished. My code looks like this: var myContext = myCanvasElement.getContext('2d'), myImg = new Image(); myImg.onload = function() { myContext.drawImage(containerImg, 0, 0, 300, 300); }; myImg.src = "someImage.png"; So now, I would like to be notified when drawImage is done. I checked the spec but I couldn't find either an event or the possibility to pass a callback function. So far I just set a

drawImage doesn't work when I refer to an image in another javascript file

元气小坏坏 提交于 2020-01-11 11:29:09
问题 (I'll show the pure javascript below) I've got these two lines of code that are, in my mind, doing the exact same thing but one of them reports an error. This appears in a file named "Rendering.coffee". Here are the two lines (in coffeescript): ... ctx.drawImage(document.getElementById("bg"), 0, 0) #this works ctx.drawImage(root.resources.bg, 0, 0) #TypeError: Value could not be converted to any of: HTMLImageElement, HTMLCanvasElement, HTMLVideoElement. ... I assign root.resources.bg in

gdi+ Graphics::DrawImage really slow~~

主宰稳场 提交于 2020-01-10 07:17:19
问题 I am using a GDI+ Graphic to draw a 4000*3000 image to screen, but it is really slow. It takes about 300ms. I wish it just occupy less than 10ms. Bitmap *bitmap = Bitmap::FromFile("XXXX",...); //-------------------------------------------- // this part takes about 300ms, terrible! int width = bitmap->GetWidth(); int height = bitmap->GetHeight(); DrawImage(bitmap,0,0,width,height); //------------------------------------------ I cannot use CachedBitmap, because I want to edit the bitmap later.

Fabric.js - problem with drawing multiple images zindex

孤人 提交于 2020-01-09 10:49:28
问题 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