gdi+

Draw image into shape?

耗尽温柔 提交于 2019-12-11 08:18:17
问题 I've made an user control that can be used as a circle/square/triangle shape, the control can draw a border (outer) and fill what its inside that border (inner) To understand it: The border is the black, and the inner is the red. Well, now I would like to add a feature in my control to fill the inner of the shape using an image. but when I try to fill only that space using an image, the outside area of the shape is also drawn: I'm not any expert using GDI+, how I can fix this? I need to do

How do I rotate image then move to the top left 0,0 without cutting off the image

人盡茶涼 提交于 2019-12-11 07:32:06
问题 How do I rotate image then move to the top left 0,0 without cutting off the image. Please read the comments inside the code. I got stuck at STEP 3 I think using trigonometry should be able to solve this problem. thanks private Bitmap RotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold rotated image Bitmap returnBitmap = new Bitmap(b.Width, b.Height); //make a graphics object from the empty bitmap Graphics g = Graphics.FromImage(returnBitmap); //STEP 1 move rotation point

Using GDI+ to draw tooltip

我与影子孤独终老i 提交于 2019-12-11 06:38:33
问题 I'm new to GDI+ programming and am looking for some advice. I am loading an image from a file and displaying it using the following functions (some pseudo code included): Gdiplus::Image *i = new Gdiplus::Image(file, other parameters ... ); Gdiplus::DrawImage(i, other parameters ... ); I would like to associate a tooltip with the image. Is there any way that I can automatically set/attach a tooltip to the Gdiplus::Image objact (or any other Gdiplus control that I wish to draw for that matter)?

c# save System.Drawing.Graphics to file

社会主义新天地 提交于 2019-12-11 06:21:39
问题 I have a System.Drawing.Graphics took from a picturebox. basically I draw some lines over a background image stored into the picturebox now I wish save a png that contains the background image and everything is drawn over there... is there a way to do this? thanks in advance 回答1: If you are drawing these lines on the Paint event then you need to create a BitMap with the BackgroundImage and call your paint function with the Bitmap's Graphics, and then call Bitmap.Save(). Bitmap bmp = new

Gdiplus Bitmap has no Alpha Channel

纵然是瞬间 提交于 2019-12-11 06:05:38
问题 I am trying to create a Gdiplus::Bitmap by a BITMAPINFO (shortened code example): BITMAPINFO bmi; HDC hdc; void* pvBits; ZeroMemory(&bmi, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = some_width; bmi.bmiHeader.biHeight = some_height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 24; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = ((((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) & ~31) >> 3) * bmi.bmiHeader

How can I check if a Bitmap Image is empty?

蓝咒 提交于 2019-12-11 05:13:00
问题 In Form1 I create in the constructor a new Bitmap: public Form1() { InitializeComponent(); de.pb1 = pictureBox1; de.bmpWithPoints = new Bitmap(pictureBox1.Width, pictureBox1.Height); de.numberOfPoints = 100; de.randomPointsColors = false; de.Init(); } In the class I check if the bitmap is null : if (bmpWithPoints == null) The bitmap is not null but is also not drawn with anything on it. I check in the class if it's null I want to draw and set points on the bitmap. if (bmpWithPoints == null) {

C# get font from postscript name

社会主义新天地 提交于 2019-12-11 03:18:52
问题 I need to get the font (System.drawing.Font), with the given postscript name. For example, if I give the input as "CourierNewPSMT", the Courier font should be loaded. Similarly if "Arial-Black" is the input, the "Arial Black" font should be loaded. Any ideas?? Note : "Arial-Black" is the postscript name of "Arial Black" font. "CourierNewPSMT" is the postcript name of "Courier New" font. Thanks in advance. Regards, James 回答1: If you're on a Mac, you can look at the font in Font Book and go

GDI+ Generic Error ASP.NET MVC

耗尽温柔 提交于 2019-12-11 02:33:28
问题 I am having a GDI+ generic error I've tried what everyone says which is make sure that the folder containing the image file that is being read in like so public ImageResult ProfileAsset(string profile, int width, int height) { PhotoDB imgstr = new PhotoDB(); Image FullsizeImage = Image.FromFile( imgstr.getFilePath(profile, false, PhotoDB.PhotoSize.None) ); Image cropedImage = imgstr.Crop(FullsizeImage, width, width, PhotoDB.AnchorPosition.Center); return new ImageResult { Image = cropedImage,

Have you had problems developing on a Virtual PC?

丶灬走出姿态 提交于 2019-12-11 01:48:42
问题 I use a virtual PC (with remote desktop connection) for my project. The project uses some GDI+ functionality. Now, apparently there is a problem when displaying graphics object on the real and virtual PC. A simple example: public class Form1 : Form { private void Form1_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; using (Pen pen = new Pen(Color.Blue, 3)) { g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias; g.DrawLine(pen, 10, 10, 50, 150); g

How can I fix this GDI+ generic exception when I save images?

浪子不回头ぞ 提交于 2019-12-11 01:38:42
问题 How can I solve this GDI generic exception? Here is the exception: System.Runtime.InteropServices.ExternalException was unhandled HResult=-2147467259 Message=A generic error occurred in GDI+. Source=System.Drawing ErrorCode=-2147467259 Code: public Bitmap resize(string FileName) { string[] settings; string inputFolder = ""; string qrFolder = ""; string generalFolder = ""; string archiveFolder = ""; string resizedArchiveFolder =""; string line; int index = 0; settings = System.IO.File