gdi+

LinearGradientBrush does not render correctly

送分小仙女□ 提交于 2019-12-23 08:17:07
问题 Consider the following code from a standard System.Windows.Forms.Form protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle test = new Rectangle(50, 50, 100, 100); using (LinearGradientBrush brush = new LinearGradientBrush(test, Color.Red, Color.Blue, 0f)) { e.Graphics.DrawRectangle(new Pen(brush, 8), test); } } It produces this result: Why are the red and blue lines showing up in the incorrect order, and how can this be fixed? 回答1: The rendering origin is the problem

How to ship gdiplus.dll but not have Windows use it?

孤者浪人 提交于 2019-12-23 05:37:10
问题 i have an application that has a dependancy on gdiplus. i need the application to also run on Windows 2000. i want to include GDIPlus in the application directory, so that Windows 2000 computers will function, but if the machine is Windows XP, Windows Vista, Windows 7, etc, i want it to use the version of GDIPlus that ships, and is updated, with Windows. Not possible? 回答1: From http://msdn.microsoft.com/en-us/library/ms997620.aspx Try adding the following to your manifest :- <?xml version="1

Justify text with DrawString right -and- left

天涯浪子 提交于 2019-12-23 04:36:24
问题 Let's say I have 200 pixels of space and I want to draw two strings into it: - the first string should be left justified - right second string should be right justified - But not overlap if they do not both fit (then do whatever my String.Trimming options say) Am I going to have to measure each and draw this manually, or does DrawString have some way to support what I'm trying to do without me reinventing the wheel? Imagine that \l and \r were escapes that did this, then I could say graphics

How to draw a signature and save it to disc as Bitmap?

断了今生、忘了曾经 提交于 2019-12-23 04:32:19
问题 I'm trying to do a signature capture program and save the customer signature to a PNG or BMP format. I have the Picturebox code working great and the results look better than using draw. I can't get the image to save. Imports System.Drawing Public Class Form1 Dim color As System.Drawing.Pen = Pens.Black Dim bmp As Bitmap Private Sub form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load bmp = New Bitmap(PictureBox1.Width, PictureBox1.Height) PictureBox1.Image = bmp End Sub Private

Why does the color after Image.Clear(x) not exactly equal the color x?

China☆狼群 提交于 2019-12-23 03:50:35
问题 The sample code for this issue is largely self-explanatory, so: [Fact] private void Color_in_should_equal_color_out() { var bitmap = new Bitmap(128,128,PixelFormat.Format32bppArgb); var color = Color.FromArgb(30,60,90,120); using (var g = Graphics.FromImage(bitmap)) { g.Clear(color); } var result = bitmap.GetPixel(0,0); Assert.Equal(color, result); } In this instance I would expect the color of the background to be identical to the color I cleared it to. Instead I get this: Assert.Equal()

GDI Handles in Windows Service vs Interactive Application

喜夏-厌秋 提交于 2019-12-23 03:06:17
问题 I have a code that is used in an Winforms application. The same code is also used in a Windows Service (exe running as Windows Service). The code grabs the handles to ICONs. But what I found is that, in Task Mangaer (and GDI View), when I ran the Winforms Application the app shows the GDI count. But when I ran the code via Windows Service, the service instance in Task Manager isn't showing any count for GDI. So, does this mean that Windows Service can never hold a GDI handle? If so, how does

Optimize drawing for paint application c#

佐手、 提交于 2019-12-23 01:58:12
问题 I am making a paint project like photoshop using c#. I have used GDI+ for the drawing. Sadly I cannot post the screen shot cuz of the reputation points required. EDIT : Ok i got enough rep to upload a pic. My drawing using the mouse lags when the brush size increases. I have a canvasBuffer which is drawn to the canvas panel protected override void OnPaint(PaintEventArgs e) { if (canvasBuffer != null) { using (Graphics g = e.Graphics) { g.DrawImage(canvasBuffer, e.ClipRectangle, e

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

我与影子孤独终老i 提交于 2019-12-22 21:40:09
问题 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

Rotating part of an image in 3D space

笑着哭i 提交于 2019-12-22 13:49:29
问题 Here's the setup: This is for an ecommerce art site where some paintings are canvas transfers. The painting wraps around the sides and top and bottom of the canvas. We have high-res images of the entire painting, but what we want to display is a quasi-3D representation of the image in which you can see how the sides of the painting wrap around the canvas. Here's a rough sketch of what I'm talking about: My question is, how can I rotate an image in 3D space? The approach I think I'd like to

Converting 24BPP to 4BPP with GDI+ in VB.NET

依然范特西╮ 提交于 2019-12-22 12:57:21
问题 My VB.NET program currently takes a 4BPP TIFF as an Bitmap, converts it to a Graphic, adds some text strings and then saves it out again as a TIFF file. The output Bitmap.Save() TIFF file by default seems to be 24BPP (regardless of the input) and is a lot larger than the original TIFF. Is it possible to keep the same 4BPP palette encoding as the input for the output and if not, how can I convert my Bitmap PixelFormat from 24BPP to 4BPP Indexed. I've seen an example for converting 24 BPP to 1