system.drawing

ImageList: Disposing the original image removes it from the list

て烟熏妆下的殇ゞ 提交于 2019-12-01 08:54:47
ImageList should create a copy of all images that are inserted into it. Therefore it should be safe to dispose the originals after adding them to the list. Why does the following testcase fail? Bitmap test = new Bitmap(128, 128); ImageList il = new ImageList(); il.Images.Add(test); Assert.AreEqual(1, il.Images.Count); // OK, image has been inserted test.Dispose(); // now let's dispose the original try { var retrievalTest = il.Images[0]; } catch (ArgumentException) // ... but this Exception happens! { } Assert.AreEqual(1, il.Images.Count); // and this will fail What seems to happen here is this

Undo button for System.Drawing?

懵懂的女人 提交于 2019-12-01 08:24:59
I am making a image editor kinda for own enjoyment and was wondering how could I make a undo button to undo the last paints I did? I want to know how I would about this, a tutorial or sample code would be nice or at least something pointing me in the right direction. Thanks! heh undo in really non that hard as it sounds. The magic here that you should record each action as object which is painted in a list or queue, f.ex, user draws a line, so your record could look like x,y of start poing, and x,y of end point or object it self which have method Draw(), so what undo will do just remove that

Bitmap.Save to save an icon actually saves a .png

社会主义新天地 提交于 2019-12-01 07:48:36
问题 I need to write a program that will generate 108 combinaisons of icons (standard windows .ico files) based on a tileset image. I use the class System.Drawing.Bitmap to build each combinaison, and I save them like this: Bitmap IconBitmap = new Bitmap(16, 16); // Some processing, writing different parts of the source tileset // ... IconBitmap.Save(Path.Combine(TargetPath, "Icon" + Counter + ".ico"), ImageFormat.Icon); But I found out that the file saved is actually a PNG. Neither Windows

Poor performance of concurrent Graphics.RotateTransform operations

﹥>﹥吖頭↗ 提交于 2019-12-01 07:37:48
问题 Why don't I see a significant speed increase when running concurrent Graphics.RotateTransform operations across multiple threads? This example demonstrates the marginal performance increase: static Bitmap rotate(Bitmap bitmap, float angle) { Bitmap rotated = new Bitmap(bitmap.Width, bitmap.Height); using (Graphics g = Graphics.FromImage(rotated)) { g.TranslateTransform((float)bitmap.Width / 2, (float)bitmap.Height / 2); g.RotateTransform(angle); g.TranslateTransform(-(float)bitmap.Width / 2,

ImageList: Disposing the original image removes it from the list

痴心易碎 提交于 2019-12-01 07:12:05
问题 ImageList should create a copy of all images that are inserted into it. Therefore it should be safe to dispose the originals after adding them to the list. Why does the following testcase fail? Bitmap test = new Bitmap(128, 128); ImageList il = new ImageList(); il.Images.Add(test); Assert.AreEqual(1, il.Images.Count); // OK, image has been inserted test.Dispose(); // now let's dispose the original try { var retrievalTest = il.Images[0]; } catch (ArgumentException) // ... but this Exception

Undo button for System.Drawing?

雨燕双飞 提交于 2019-12-01 06:09:36
问题 I am making a image editor kinda for own enjoyment and was wondering how could I make a undo button to undo the last paints I did? I want to know how I would about this, a tutorial or sample code would be nice or at least something pointing me in the right direction. Thanks! 回答1: heh undo in really non that hard as it sounds. The magic here that you should record each action as object which is painted in a list or queue, f.ex, user draws a line, so your record could look like x,y of start

Use a System.Drawing.Image in an HTML tag

假如想象 提交于 2019-12-01 05:54:59
问题 I have a potentially easy question. I have an image stored in a database, I then used a C# method in my application that gets that image and stores it in a custom class that looks like this: public class MyImage { public System.Drawing.Image myImageFromDB; public string imageName; public int imageNumberInCollection; } My question is this: Can I/How can I use the image from this class in an HTML image tag? I have attempted the following but it just returns a box with a red X in it: /

How to add System.Drawing in xamarin?

﹥>﹥吖頭↗ 提交于 2019-12-01 04:14:35
I am trying for some time now to add System.Drawing to the references in Visual Studio 2015. Nothing seems to work. When I go into the add reference pane, there is no System.Drawing in the list. I need the Bitmap class from System.Drawing not one from Android.Graphics As @Cheesebaron quoted once if forum : If you look at http://docs.xamarin.com/guides/android/advanced_topics/assemblies you will see that System.Drawing is not a part of the Assemblies shipped with Xamarin.Android, the same goes for Xamarin.iOS. You will need to use the Android counterparts to filter images. The alternative

How to know if a GraphicsPath contains a point in C#

岁酱吖の 提交于 2019-12-01 03:47:45
I'm using .NET to draw a diagram, and I want to highlight objects when the user performs a click on them. It is easy when a figure is fully contained in a rectangle: if (figure.Bounds.Contains(p)) // bounds is a rectangle But I don't know how to manage it if the figure is a complex GraphicsPath . I have defined the following GraphicsPath for the figure (the green circle). I want to highlight the figure when the user click on it. I would like to know if a Point is contained in that GraphicsPath . Any ideas? Thanks in advance. I don't know a DrawingPath (you mean probably; graphics.DrawPath) but

InterpolationMode HighQualityBicubic introducing artefacts on edge of resized images

假如想象 提交于 2019-12-01 03:15:53
Using some pretty stock standard C# code to resize an image, and place it on a coloured background Image imgToResize = Image.FromFile(@"Dejeuner.jpg"); Size size = new Size(768, 1024); Bitmap b = new Bitmap(size.Width, size.Height); Graphics g = Graphics.FromImage((Image)b); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.FillRectangle(Brushes.Green, 0, 0, size.Width, size.Height); g.DrawImage(imgToResize, new Rectangle(0,150,768, 570)); b.Save("sized_HighQualityBicubic.jpg"); The result has a funny artefact in the 0th and 1st columns of pixels. The 0th column appears to be mixed