system.drawing

wpf - Can i use System.Drawing in wpf?

余生长醉 提交于 2019-11-28 08:12:23
问题 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

How can I iterate through each pixel in a .gif image?

纵饮孤独 提交于 2019-11-28 07:37:40
I need to step through a .gif image and determine the RGB value of each pixel, x and y coordinates. Can someone give me an overview of how I can accomplish this? (methodology, which namespaces to use, etc.) Vinko Vrsalovic This is a complete example with both methods, using LockBits() and GetPixel(). Besides the trust issues with LockBits() things can easily get hairy. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace BitmapReader { class Program { static void Main(string[] args) { //Try a small pic to be able to compare

C# Drawstring Letter Spacing

只谈情不闲聊 提交于 2019-11-28 07:11:47
问题 Is is somehow possible to control letter spacing when using Graphics.DrawString? I cannot find any overload to DrawString or Font that would allow me to do so. g.DrawString("MyString", new Font("Courier", 44, GraphicsUnit.Pixel), Brushes.Black, new PointF(262, 638)); By letter spacing I mean the distance between letters. With spacing MyString could look like M y S t r i n g if I added enough space. 回答1: That's not supported out of the box. You'll either have to draw each letter individually

Dynamically resizing font to fit space while using Graphics.DrawString

拟墨画扇 提交于 2019-11-28 06:56:02
Does anyone have a tip whereas you could dynamically resize a font to fit a specific area? For example, I have an 800x110 rectangle and I want to fill it with the max size font that would support the entire string I'm trying to display. Bitmap bitmap = new Bitmap(800, 110); using (Graphics graphics = Graphics.FromImage(bitmap)) using (Font font1 = new Font("Arial", 120, FontStyle.Regular, GraphicsUnit.Pixel)) { Rectangle rect1 = new Rectangle(0, 0, 800, 110); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment =

WIndows universal app with system.drawing and possible alternative

天涯浪子 提交于 2019-11-28 06:29:16
问题 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 回答1: 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

Drawing a line in Winforms

丶灬走出姿态 提交于 2019-11-28 03:55:31
问题 I am having trouble drawing a line within a group box in a simple windows form. here is my code: public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); DrawLShapeLine(groupBox1.CreateGraphics(), 10, 10, 20, 40); } public void DrawLShapeLine(System.Drawing.Graphics g, int intMarginLeft, int intMarginTop, int intWidth, int intHeight) { Pen myPen = new Pen(Color.Black); myPen.Width = 2; // Create array of

Graphics object to image file

♀尐吖头ヾ 提交于 2019-11-28 03:13:53
问题 I would like to crop and resize my image. Here is my code: Image image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Cropper/tests/castle.jpg"); // Crop and resize the image. Rectangle destination = new Rectangle(0, 0, 200, 120); Graphics graphic = Graphics.FromImage(image); graphic.DrawImage(image, destination, int.Parse(X1.Value), int.Parse(Y1.Value), int.Parse(Width.Value), int.Parse(Height.Value), GraphicsUnit.Pixel); Now I assume that my resulting cropped/resized image is

Loading a file to a Bitmap but leaving the original file intact

别说谁变了你拦得住时间么 提交于 2019-11-28 00:42:04
问题 How to do this in C#? If I use Bitmap.FromFile(), the original file is locked. If I use Bitmap.FromStream(), the original file is not locked, but the documentation says "You must keep the stream open for the lifetime of the Image." This probably means that the file is still linked to the image object, (for example, perhaps if the file change so do the object or vice versa). what i want to do is just reading the bitmap and save it to an object and after that there is no link whatsoever between

.NET: What does Graphics.DrawImageUnscaled do?

两盒软妹~` 提交于 2019-11-27 23:36:41
It is not well known , that if you draw an image, e.g.: graphics.DrawImage(image, top, left); the image will be scaled. This is because DrawImage looks at the dpi setting of the image (e.g. 72dpi from photoshop), and scales the image to match the destination display (typically 96dpi). If you want to draw an image without any scaling, you must explicitly give DrawImage the size of the image: graphics.DrawImage(img, top, left, img.Width, img.Height); i knew this from years of programming in GDI+. The same fact exists in the .NET System.Drawing wrappers around GDI+ - if you want to draw an image

System.Drawing.Brush from System.Drawing.Color

强颜欢笑 提交于 2019-11-27 22:43:44
I'm developing a WinForm Printing application for our company. When the document is printed, I need to take the System.Drawing.Color property of each Control on the document and create a System.Drawing.Brush object to draw it. Is there a way to convert the System.Drawing.Color value to a System.Drawing.Brush value? NOTE: I've tried looking into the System.Windows.Media.SolidColorBrush() method, but it does not seem to be helpful. Use the SolidBrush class: using (SolidBrush brush = new SolidBrush(yourColor)) { // ... } Why not the GDI+ brush? http://msdn.microsoft.com/en-us/library/system