system.drawing

Optimising PNG output from System.Drawing in .NET [closed]

为君一笑 提交于 2019-12-01 18:46:40
I have a routine which reads in an image, resizes it and positions it on a new background (brand new bitmap, just the size is set). This all works absolutely perfectly, but now I would like to reduce the size of the PNG files it outputs - if I output JPEG files, I get the ~4K or so file size I expect, but my PNG files are more than 30K in size. I know that I will never get to JPEG levels with PNG, but I think I can do a bit better. When I load the outputted PNGs into Fireworks , I note that the background and the resized image are still seperate layers. Flattening the PNG in Fireworks reduces

How can I scale up the hatchstyle drawn in a rectangle? [closed]

99封情书 提交于 2019-12-01 18:33:23
I'm using .Net drawing to draw a diagram. It is essentially a stacked bar chart. The issue I have is that I want to reduce the amount of lines in the hatch style so in a way scale it up to make it clearer. I've looked around but didn't come across anything that could help me. I draw a rectangle and then use a hatchbrush to fill it but due to image size the hatchfill becomes less clearer. Thank you for any suggestions. The hatchStyles and brush types are stored in the db and I use a helper function to return them. So I draw the rectangle and after getting the brush I fill the rectangle.

How can I scale up the hatchstyle drawn in a rectangle? [closed]

江枫思渺然 提交于 2019-12-01 17:48:04
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I'm using .Net drawing to draw a diagram. It is essentially a stacked bar chart. The issue I have is that I want to reduce the amount of lines in the hatch style so in a way scale it up to make it clearer. I've looked around but didn't come across anything that could help me. I draw a rectangle and

wpf - Can i use System.Drawing in wpf?

∥☆過路亽.° 提交于 2019-12-01 17:14:24
i am saving the image in database. .. but how to retrieve that image from database .. when i try to use system.drawing .. it shows an error .. some of ppl saying i can't use system.drwaing in wpf .. not even dll file .. my code is private void btnShow_Click(object sender, RoutedEventArgs e) { DataTable dt2 = reqBll.SelectImage().Tables[0]; byte[] data = (byte[])dt2.Rows[0][1]; MemoryStream strm = new MemoryStream(); strm.Write(data, 0, data.Length); strm.Position = 0; System.Drawing.Image img = System.Drawing.Image.FromStream(strm); BitmapImage bi = new BitmapImage(); bi.BeginInit();

WIndows universal app with system.drawing and possible alternative

≡放荡痞女 提交于 2019-12-01 11:50:47
I'm developing a windows universal app and i need to work with Bitemap but i cannot seem to reference System.Drawing, Why cant windows universal app cannot reference this dll and what alternative do i have? Edit Any suggestions on how can i use my already written filtering library (that depends on system.drawing) in a universal app? Tnx System.Drawing is the .NET namespace for working with GDI+. This technology is not available for Windows Store apps or universal Windows Apps. See .NET for Windows apps . You can make use of the Win2D project for a WinRT wrapper usable from C# for drawing with

Drag and drop rectangle in C#

吃可爱长大的小学妹 提交于 2019-12-01 11:17:12
I want to know how to draw rectangle in C# and make it dragged and dropped in the page here my code to draw it but I cannot drag or drop it. public partial class Form1 : Form { public bool drag = false; int cur_x, cur_y; Rectangle rec = new Rectangle(10, 10, 100, 100); public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs r) { base.OnPaint(r); Graphics g = r.Graphics; //g.DrawRectangle(Pens.Black, rec); g.FillRectangle(Brushes.Aquamarine, rec); } private void recmousedown(object sender, MouseEventArgs m) { if (m.Button != MouseButtons.Left) return; rec = new

Poor performance of concurrent Graphics.RotateTransform operations

心已入冬 提交于 2019-12-01 11:04:33
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, -(float)bitmap.Height / 2); g.DrawImage(bitmap, new Point(0, 0)); } return rotated; } static void Main

Use a System.Drawing.Image in an HTML tag

大城市里の小女人 提交于 2019-12-01 09:29:32
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: //myImageFromDBCollection is a list of MyImage objects foreach(var ind in myImagesFromDBCollection) { table +=

Drag and drop rectangle in C#

夙愿已清 提交于 2019-12-01 09:07:09
问题 I want to know how to draw rectangle in C# and make it dragged and dropped in the page here my code to draw it but I cannot drag or drop it. public partial class Form1 : Form { public bool drag = false; int cur_x, cur_y; Rectangle rec = new Rectangle(10, 10, 100, 100); public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs r) { base.OnPaint(r); Graphics g = r.Graphics; //g.DrawRectangle(Pens.Black, rec); g.FillRectangle(Brushes.Aquamarine, rec); } private

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

送分小仙女□ 提交于 2019-12-01 08:56:14
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 Explorer nor Visual Studio can display it correctly, but GIMP can, and if I open it in an Hex viewer, here is