Questions tagged [system.drawing]
System.Drawing is a namespace of the .NET framework. It provides access to GDI+ basic graphics functionality.
1,121
questions
0
votes
1
answer
27
views
Pixelformat in .net 7 for System.Drawing.Bitmap is mixing up R and B values in 24 bit RGB
So I'm using System.Drawing Bitmap implementation. It looks like when setting format to PixelFormat.Format24bppRgb its actually interpreting it as 24 Bgr and not Rgb
latestImage = new Bitmap(bitmap....
-1
votes
0
answers
58
views
Correct way to process images with System.Drawing in C#?
I'm currently working on a project where I need to add various effects, layers, and do zoom and pan on an image in a Bitmap that is displayed in a PictureBox. I've written some code to accomplish this,...
0
votes
0
answers
30
views
How to cancel PrintPreviewControl print when exception occurs after selecting locked file
This is about printing to file like print to pdf and the like.
My problem is that when user selects locked file through SaveFileDialog-like window PrintDocument.Print() throws Win32Exception. I catch ...
2
votes
1
answer
75
views
how to get a specific icon from an icon library? [duplicate]
I have this snippet of code to extract an icon from shell32.dll.
$iconPath = "$env:SystemRoot\system32\shell32.dll" # Path to the shell32.dll library
$iconIndex = 4 # Index of the folder ...
-2
votes
1
answer
55
views
How to draw these triangles in C# and save the result in BMP image format?
What i need to draw
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
class Program
{
static void Main(string[] args)
{
int ...
1
vote
0
answers
45
views
Why do I keep getting the wrong color?
I am trying to change the color of all the arrows in a document to red. However, they keep changing to blue.
I tried this:
$shapes = $doc.Shapes
foreach ($shape in $doc.Shapes) {
if($shape.Name -...
0
votes
0
answers
82
views
c# system.drawing how to print pdf to whole page size without blurr and losing quality
I made a windows service that's runs in background service and listening for web app to order to print.
the web app send a pdf file and width and height of the printer paper with count of copies
I ...
2
votes
1
answer
140
views
Unable to load libgdiplus in Signal R web application with web sockets (Mac OS)
I downloaded this repository from GitHub and try to run it on my MacOS laptop. It uses Signal R and web sockets.
It builds, it starts, it works
But when I try to open web socket I get an error:
...
0
votes
0
answers
10
views
System.IndexOutOfRangeException in c# window form
I have been trying too parse 2 parameter using for loop but it only loop once and locates one parameter. This is my code.
By providing rectangle 70,80 command in the form, I am trying to draw shapes ...
0
votes
0
answers
35
views
How to resize and overlay, in C#, 2 images using some points as reference
I have 2 Bitmap (bmpA and bmpB) and in each I drawn a Line between 2 Points.
These lines have different length.
First:
I want to scale bmpB so that the line drawn in it have to be the same of the ...
0
votes
0
answers
38
views
CA1416: Validate platform compatibility in Resource.Image.Save
I'm using dotnet 7.0
I have an image in my resources, and I want to convert it to byte array in all platforms.
I wrote the following:
await using var memoryStream = new MemoryStream();
Resources....
0
votes
0
answers
35
views
How to generate an image using System.Drawing in .net core
I feel like this question should have been answered like dozens of times but I'm blind to find one.
I would like to generate an image using System.Drawing and without using Bitmap (only Windows ...
1
vote
1
answer
130
views
State image shows obvious pixel defects when drawing WinForms TreeView
On my brand new Windows 11 desktop, the bitmap I've been using to indicate a 'connected database' state in my stable production app is suddenly looking terrible on my 4K 150% scaled display (the ...
0
votes
0
answers
127
views
C# .NET Framework 4.8 Class library can't load Bitmap from System.Drawing
My .net Frameowkr Class Library runs on version 4.8, System Drawing reference is Version 4 and System.Drawing.Common is Version 7.
Here is a minimal working prototype:
using System.Collections.Generic;...
0
votes
0
answers
7
views
Is there a way to have the panel disable only the drawn lines without losing controls like button C# winform
Recently I have a small project to create a program to demonstrate DFS and BFS algorithms, but I am having trouble with the console. specifically when I don't // mypanel.invalidate() in the eventpaint ...
0
votes
1
answer
299
views
System.Drawing.Common not working on Windows
I'm trying to run a simple C# Application on windows 11. I'm using the System.Drawing to edit a png file, but this error is occuring.
System.PlatformNotSupportedException: 'System.Drawing.Common is ...
0
votes
1
answer
942
views
System.Drawing.Image to SkiaSharp
I am trying to move my code from using System.Drawing.Image to using SkiaSharp as recommended here.
I trying to find similar operations for working with Tif files from a stream.
Currently, the ...
1
vote
0
answers
202
views
Converting webp to png with .NET in Unity
So, I have a webp image bytes which I get from decoding base 64 string, but the thing is that Unity can not understand webp Images, so I have changed Unitys default .NET 2.1 to .NET Framework 4.x to ...
1
vote
1
answer
60
views
How do I check whether a Bitmap pixel is touching another Color? (C#)
I'm attempting to check if a pixel in a bitmap is touching another pixel of a certain color but I'm not quite sure how to do it.
So far, I can iterate through the pixels like this:
for (...
0
votes
0
answers
37
views
Why is the SSRS Barcode breaks up with a space in between?
I have a SSRS report which I've initially created with SQL Server 2014 Report Builder (12.0.6024.0) using Code128 according to this post. It has been working great until we wanted to upgrade our SQL ...
0
votes
0
answers
45
views
How to increase Dots size in rectangle
How to increase the white dots sizes? Please refer the attached image.
How to increase dot size to bigger size? I have tried multiple ways to increase size of the dots
using System;
using System....
0
votes
1
answer
55
views
Change mouse cursor just when mouse is top of line or inside of closed path in C#
I want to set event property or change mouse cursor when hover a line, created by Graphics class.
I can set this property for a panel, that contain line, but I want to change mouse cursor just when ...
4
votes
1
answer
794
views
.NET 6/7 Migration from System.Drawing.Common to Microsoft.Maui.Graphics
With .NET 7 System.Common.Drawing is no longer useable in not windows platforms. I like to migrate my application to Microsoft.Maui.Graphics (as Microsoft suggests on their breaking changes page for ....
1
vote
1
answer
48
views
Self-intersecting GraphicsPath with z-order
I need to create a framed GraphicsPath that self-intersects giving a z-order feeling:
The code that I used to obtain the image is the following:
private void Example1(PaintEventArgs e) {
Brush ...
0
votes
1
answer
754
views
.NET 6: Transitioning from System.Drawing to SkiaSharp for Tiff to PDF conversion
I am trying several ways to remove System.Drawing due to the pending removal of the workaround in .NET 7. I am trying to use SkiaSharp to replace those calls but am having trouble.
The following is ...
0
votes
1
answer
125
views
Rectangle bounds of rotated image
I am drawing an image rotated with Graphics transform, but I am unable to get the position and size of the rotated image.
Paint event:
graphics.TranslateTransform(BaseX, BaseY);
graphics....
0
votes
0
answers
250
views
Difference in SkiaSharp measureText and System Drawing's measureText
I am trying to find out the a character's width and height in windows environment using this code:
using(Graphics g = Graphics.FromImage(new Bitmap(800,550)))
{
g.TextRenderingHint = System....
0
votes
1
answer
84
views
Wrong value of FontFamily GetCellDescent
The value of descent I get from System.Drawing.FontFamily.GetCellDescent for some fonts is different from values of I get when the font is read by other APIs/sources (e.g. SixLabors.Fonts library or ...
-2
votes
1
answer
125
views
C# Graphics class want to make signature panel : input from drawing tablet
i am trying to make signature panel in c# windowsform application where input is from drawing tablet
my code as below this code working for line drawing not dot created.
So please suggest how dot and ...
0
votes
0
answers
30
views
Simple ways to interchange image data between System.Drawing and Windows.UI.Xaml.Media.Imaging
For example, given a Bitmap, how to create a WriteableBitmap then copy the content of the Bitmap into the WriteableBitmap?
Although brutal force methods such as first get byte[] from the Bitmap, then ...
0
votes
1
answer
78
views
How to remove overlapping rectangles (C#, System.Drawing) while keeping only the one with a certain attribute?
For a class that stores template matching results, I need to implement a efficent way of removing overlapping results (= overlapping bounding boxes, for e.g. this happens for low accuracy thresholds ...
0
votes
1
answer
592
views
Simple image operations for .NET Core 6 and beyond
I have some C# code that relies on doing really basic graphic operations such as getting and setting pixels, and drawing texts over images. This uses the System.Drawing package which Microsoft has ...
0
votes
0
answers
167
views
System.Drawing.Image 'Parameter is not valid' when image source is from Android
I am developing a Blazor WASM app to interface with the backend of a winforms application. Images in this winforms application are loaded with System.Drawing.Image.FromStream().
Images that are ...
0
votes
0
answers
103
views
error using the webp libraries for c#, return type mismatch with dllimport?
I am trying to use a wrapper for the webp library in Visual Studio Community 2022/2019 in c# for a dll in a Rimworld mod but i keep getting the same error result on runtime with different libraries.
...
0
votes
0
answers
106
views
System.OutOfMemoryException in System.Drawing.dll while hovering chart if stepline selected as ChartType and annotations in use
Why on earth this very simple c# code with two series is throwing OutOfMemory exception from System.Drawing.dll when chart is mouse hovered?
public Form1()
{
...
0
votes
0
answers
28
views
How to add a bottom layer to an existing object Graphics (System.Drawing namespace) [duplicate]
I have a Windows Form application developed in C# with Net Framework 4.8.
In this app I have a PictureBox control that shows an image. I can rotate the image in the PictureBox but after rotation in ...
1
vote
0
answers
161
views
Difference between MeasureString in System.Drawing and TextMeasurer.Measure in SixLabors
I have two Methods to return width of string:
The first method is using System.Drawing:
public static float GetTextWidth(string fontFace, float fontSize, string text)
{
var fontx = new System....
0
votes
0
answers
96
views
C# System.Drawing.DrawImage() draws bitmap in wrong place
I have a panel control and a bitmap with the same size. When I resize the panel I want the bitmap to be drawn on it. I use DrawImage(Image, Int32, Int32, Int32, Int32)
This is the panel (Canvas) Paint ...
0
votes
0
answers
78
views
C# Print Server Side ASP.NET service or Windows Service without Syste.Drawing
I develope, some years ago, a SOAP Web Service that print Microsoft.ReportViewer reports called by clients.
This service is installed in several systems but in one, with a higher load, it stops ...
0
votes
0
answers
391
views
System.Drawing.Common assembly not loading
im using dotnet 6 and in dotnet 6 the Bitmap package was moved to a download only package, no problem here, I just installed it using dotnet Add-Package, but it still says it could not find the ...
0
votes
1
answer
541
views
A generic error occurred in GDI+ while saving image to MemoryStream
Hi i'm getting to following exception 'System.Runtime.InteropServices.ExternalException at System.Drawing.Image.Save' when trying to save JPEG file to a memory stream.
images = new List<Bitmap>(...
0
votes
0
answers
296
views
using System.Drawing not working in C# when executed in Linux Environment [duplicate]
I am generating an excel programmatically, but it works fine in VS, when I tried automating it and compiling via Linux environment, it shows error.
`
using System.Drawing;
ws1.View.FreezePanes(2, 1);
...
0
votes
1
answer
667
views
How convert SixLabors.ImageSharp.Color to System.Drawing.Color?
I need to convert instance of SixLabors.ImageSharp.Color to System.Drawing.Color and backwards. How to do it?
0
votes
1
answer
86
views
Fill a Rectangular with an inflating Circle without crossing its borders (Ripple)
I have a control surface (my custom control) and a drawed rectangular smaller than the whole surface. Now I need to draw a circle (FillEllipse) within this rectangular and the circle must not overdraw ...
1
vote
1
answer
700
views
C# System.Drawing Reference issue
I'm a total noob when it comes to C#, C++ (C anything) and visual studio.
I'm trying to draw a table over a chart using
public override void OnPaintChart(PaintChartEventArgs args)
{
...
0
votes
0
answers
54
views
How to change the position of 2nd rectangle when 1st rectangle is moved?
I'm drawing 2 rectangles in emgu/c# & I know their positions in the Image. I want to move the 2nd rectangle when the 1st is moved, while keeping the distance between them the same. What is the ...
0
votes
1
answer
107
views
Metafile size incorrect in console app, correct in Windows Forms
The below code is supposed to generate an Enhanced Windows Metafile (EMF) with a size 200mm by 100mm and a centered rectangle of 180mm by 80mm. When run from a Windows Forms application, it works. ...
2
votes
0
answers
206
views
In Powershell convert image to BMP 16 bits
I have a code to batch convert a folder of jpg files to BMP.
The code i have works OK, but it gets saved as BMP 24 bits.
I need it to convert it to BMP 16 bits using Powershell
function ConvertImage{
...
1
vote
1
answer
160
views
C# Fastest way to replace bunch of colors in high quality Image?
I have some 4k images (.png, 3840p*2160p) in which I want to replace around 2500 colors each.
I have an Color[] Array of the 2500 current Colors and one with 2500 new Colors that are always different.
...
1
vote
0
answers
324
views
How to save image via url from xml file C#
I am a newbie for c# I want to know how I download images by URL in my XML file.
Now, I am writing the code for reading XML
using (XmlReader xmlReader = XmlReader.Create(pathXml))
{
...