drawimage

DrawImage() function over WinForms does not work correctly

拥有回忆 提交于 2019-12-08 00:33:18
问题 i've created a BitMap 1 pixel wide & 256 pixel height when i try to draw this bitmap as 2 pixels wide using: public void DrawImage(Image image,RectangleF rect) the bitmap is not drawn correctly because there are white slim stripes between each bitmap column. see the simple code below private void Form1_Paint(object sender, PaintEventArgs e) { Graphics gr = e.Graphics; Bitmap bitmap = new Bitmap(1, 256); for (int y = 0; y < 256; y++) { bitmap.SetPixel(0, y, Color.Red); } RectangleF rectf = new

How to flip an image with the HTML5 canvas without scaling

孤街浪徒 提交于 2019-12-08 00:27:22
问题 I use the HTML5 canvas element to display an image in a web application and I want to flip the image horizontally without applying a scaling transformation to the canvas. This means that I do not want to use CanvasRenderingContext2D.scale() for this purpose, because I don't want to flip anything else. // I don't want this, because it breaks the rest of the application. I have // implemented zooming and landmark placement functionality, which no longer // work properly after scaling. ctx.save(

GDI+ DrawImage of a JPG with white background is not white

一世执手 提交于 2019-12-06 13:31:13
I am displaying a JPG in a C++ CWnd window using GDI+. The JPG has a pure white background, 0xffffff, but when displayed using graphics.DrawImage, the background is off-white with a mix of pixel colors such as 0xfff7f7, 0xf7fff7, 0xf7f7f7. Below is the code, I have tried various settings such as CompositingMode, SmoothingMode, etc. The image is not scaled. The weird thing is that the background color is different depending on other non-white content in the image. If I make a simple all white JPG, then it works, or even a mostly white with just some black text. Comparison of images are shown

How to display a PictureBox from behind code in C#

落爺英雄遲暮 提交于 2019-12-04 10:25:57
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, PaintEventArgs e) { e.Graphics.DrawImage(squareImage, pos_x, pos_y, 50, 50); } squareImage is an

A reusable function to clip images into polygons using html5 canvas

浪尽此生 提交于 2019-12-04 09:31:53
Guess the title of the post may need editing, but for now I don't know where the problems are. I have read pages and answers to similar questions, here and elsewhere. One Stack Overflow answer is especially close, but I don't understand it. I want a function, to draw polygons on canvas at desired coordinates and to fill them with some background image loaded from a file (large enough that no tiling is needed). Triangles would be fine for a test. Apparently I should use drawImage and clip, and to give the polygon a border, I can resuse the same path for the clip and the stroke. Also apparently

cannot display Image

旧巷老猫 提交于 2019-12-04 02:35:33
问题 I'm new being in programming, can you please tell me what is the problem in my code. The fillOval is operating well but trying to replace it with .gif file get failed, window is opened by nothing is viewed... import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; import java.io.File; import java.io.IOException; import

gdi+ Graphics::DrawImage really slow~~

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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. How can I improve it? Or is any thing wrong? This

Blank screen using DrawImage method

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have to draw a bitmap image using DrawingContext.DrawImage method. Using the code below everything is working correctly: BitmapImage myImage = new BitmapImage(); myImage.BeginInit(); myImage.UriSource = new Uri("image.png", UriKind.Relative); myImage.EndInit(); Rect area = new Rect(new Size(myImage.PixelWidth, myImage.PixelHeight)); DrawingVisual myVisual = new DrawingVisual(); using (DrawingContext context = myVisual.RenderOpen()) { context.DrawImage(myImage, area); } But only if the image does not exceed 2Mb about, i.e. the area (

IndexSizeError on drawImage on IE and Edge

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am finding that a certain code fails in Internet Explorer and Edge, but seems to work flawlessly in Chrome and Firefox: var image = document.getElementById("myImage"); var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.drawImage(image, 1, 0, 499, 278, 0, 0, 749, 417); img { width: 300px; height: 200px; } <img id="myImage" src="https://image.ibb.co/bsANfm/emptyphoto.png" /> <canvas id="myCanvas" width="600" height="400"></canvas> For some reason, the CanvasRenderingContext2D.drawImage() call

canvas drawImage图片不显示问题

匿名 (未验证) 提交于 2019-12-02 23:43:01
初次学习canvas,用来做笔记记录下遇到的问题及解决方案 这里是要将一张图片写到canvas里,按照网上搜索,初写了段代码,可是却没显示,以为是路径问题,不能跨域名使用,后来改为相对路径后,仍然无效,如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <img src="./ws.jpg" alt="" style="width: 100px;" id="imgDom"> <canvas id="myCanvas" width="300" height="300">Your browser does not support the HTML5 canvas tag.</canvas> <script> var can = document.getElementById("myCanvas"); var ctx = can.getContext("2d"); var imgDom = document.getElementById("imgDom"); ctx.drawImage(imgDom, 0, 0); </script> </body> </html> 后来经过搜索发现,是加载顺序的原因,很简单对不对?