drawimage

java drawimage()方法

匿名 (未验证) 提交于 2019-12-02 21:53:52
方法可以使用那两种格式。像这样使用: myImage = getImage(URL); //只能在Applet 子类里 myImage = Toolkit.getDefaultToolkit().getImage(filenameOrURL); Toolkit 明了两个getImage 方法: Image getImage(URL url) Image getImage(String filename) 安全限制找到有关不被信任的applets的限制方面资料. Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image1 = toolkit.getImage("imageFile.gif"); Image image2 = toolkit.getImage(new URL("http://java.sun.com/graphics/people.gif")); 方法: Image getImage(URL url) Image getImage(URL url, String name) Image image1 = getImage(getCodeBase(),"imageFile.gif"); Image image2 = getImage(getDocumentBase(),"anImageFile.jpeg");

crop image to 4:3 aspect ratio c#

僤鯓⒐⒋嵵緔 提交于 2019-12-02 11:48:21
问题 I'm having a tough time wrapping my head around how to figure out the math for cropping any image that has a higher aspect ratio than 4:3 to 4:3. For example, I may have some images that are 16:9 that I I want resized and then cropped to 4:3. The resize bit I already have working, but it's maintaining the same aspect ratio. I know I need to use Graphics.DrawImage() But I'm not entirely sure what the parameters should be nor how I derive those parameters. Here's what I do know: var dimension =

crop image to 4:3 aspect ratio c#

元气小坏坏 提交于 2019-12-02 05:28:18
I'm having a tough time wrapping my head around how to figure out the math for cropping any image that has a higher aspect ratio than 4:3 to 4:3. For example, I may have some images that are 16:9 that I I want resized and then cropped to 4:3. The resize bit I already have working, but it's maintaining the same aspect ratio. I know I need to use Graphics.DrawImage() But I'm not entirely sure what the parameters should be nor how I derive those parameters. Here's what I do know: var dimension = (double)bigSide/smallSide if(dimension > 1.4) { Graphics.DrawImage(resImage, new Rectangle(?, ?, ?, ?)

小程序drawImage()绘制网络图片生成图片保存到本地真机不显示

大兔子大兔子 提交于 2019-12-01 20:59:57
标题有点绕,问题是这样的:小程序用canvas绘制一包含图片的内容使用自带的API:drawImage,然后将其生成图片保存到相册,pc端模拟器可以完美实现,然而真机生成图片没有所绘制的图片。 原因是这样的: 首先看小程序官方文档上drawImage的用法: const ctx = wx.createCanvasContext('myCanvas') wx.chooseImage({ success: function(res){ //res.tempFilePaths[0] 为图片路径 ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100); ctx.draw(); } }) 而问题所在就是该方法的第一个参数,图片路径这里。 小程序的canvas绘制图片,图片路径必须为本地的路径,而不能是网络路径。 因此在绘制网络图片时必需先将其保存到本地然后在绘制。当我们在加载一个带有图片的页面时,图片都会被暂存到本地,由此我们可以通过 wx.gerImageInfo 接口访问本地的暂存路径来调用drawImage方法绘制图片。如下:( 注意网络图片的地址一定要在合法域名内 ) //获取网络图片本地路径 wx.getImageInfo({ src: that.data.qrCodeUrl,//服务器返回的图片地址 success:

AlphaComposite Transparency with repaint overlaps into black

拜拜、爱过 提交于 2019-12-01 10:45:11
So I have an image on top of another panel, and that image is transparent so you can see the panel beneath it. What I'm trying to do is use repaint() to fade the image (which is drawn with the drawImage() method in java.awt.Graphics) out until it is completely transparent so you can see the panel beneath it clearly. As of now, the image is just fading into black instead of into a transparent texture. This is a little bit of my code right now: paintComponent method: public void paintComponent(Graphics g) { super.paintComponent(g); float alpha = 1f-(.01f*(float)opcounter); Graphics2D g2d =

AlphaComposite Transparency with repaint overlaps into black

安稳与你 提交于 2019-12-01 06:20:41
问题 So I have an image on top of another panel, and that image is transparent so you can see the panel beneath it. What I'm trying to do is use repaint() to fade the image (which is drawn with the drawImage() method in java.awt.Graphics) out until it is completely transparent so you can see the panel beneath it clearly. As of now, the image is just fading into black instead of into a transparent texture. This is a little bit of my code right now: paintComponent method: public void paintComponent

HTML5 Canvas drawImage with video source not working on Android

眉间皱痕 提交于 2019-11-30 20:50:43
I am trying to use canvas's drawImage method with video source, but it's not working in Android 4.4.2, tested with Chrome browser. Here's my code: $(function() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var video = document.getElementById('video'); var videoWidth; var videoHeight; var paused = false; canvas.addEventListener('click', function() { if (paused) { video.play(); } else { video.pause(); } paused = !paused; }); video.addEventListener("loadedmetadata", function() { videoWidth = this.videoWidth || this.width; videoHeight = this.videoHeight ||

How to avoid HTML Canvas auto-stretching

笑着哭i 提交于 2019-11-30 10:59:24
I have the following piece of HTML: <style type="text/css"> #c{width:200px;height:500px} </style> <canvas id="c"></canvas> <script type="text/javascript"> var i = new Image(); i.onload = function () { var ctx = document.getElementById('c').getContext('2d'); ctx.drawImage(i, 0, 0); } i.width = i.height = 20; // actual size of square.png i.src = 'square.png'; </script> The issue is that the drawn image is automatically stretched (resized) proportionally with the size of the canvas. I have tried using all available parameters ( drawImage(i, 0, 0, 20, 20, 0, 0, 20, 20) ) and that didn't help. What

drawImage() not working

女生的网名这么多〃 提交于 2019-11-30 05:56:55
I am reading through "Making Isometric Social Real-Time Games with HTML5, CSS3 and Javascript." I am not far into it, and I have run into a canvas problem that has ahd me stumped for most of the day. drawImage() does not seem to be drawing. I have researched the issue and have tried many permutations of pre-loading the image, but so far nothing is working. Here is my code: HTML: <canvas id="game" width="100" height="100"> Your browser doesn't include support for the canvas element. </canvas> CSS: html { height:100%; overflow:hidden } body { margin:0px; padding:0px; height:100%; } and js:

How to increase performance over GDI's DrawImage(Unscaled)?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 05:25:53
问题 In my user control's paint handler I iterate over a collection of predefined Bitmap objects and draw them to the client area thusly: C# version: private void Control_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; foreach (BitmapObj bmpObj in _bitmapObjCollection) { g.DrawImageUnscaled(bmpObj.Bitmap, bmpObj.Location); } } VB.NET version: Private Sub Control_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim g As Graphics = e.Graphics For Each