1,140 questions
0
votes
0
answers
119
views
Graphics.DrawString Drawing Text in Incorrect Units
Graphics.DrawString(string, Font, Brush, RectangleF, StringFormat) is drawing my text in DisplayUnits (1/100th inch) when it should be drawing it in Points (1/72 inch).
It's not the bounding layout ...
0
votes
0
answers
28
views
How to find the margins specified in Windows for a printer form?
In Windows the settings of paper sizes supported by the printers (found under Print Server Properties/Forms) include paper size and margins
However, the class System.Drawing.Printing.Papersize ...
-6
votes
2
answers
148
views
Why is flipping a PNG changing the quality of the image?
I have the following code:
System.Drawing.Image img1 = System.Drawing.Image.FromFile(imgPath);
System.Drawing.Image img2 = System.Drawing.Image.FromFile(imgPath);
img2.RotateFlip(RotateFlipType....
-1
votes
1
answer
97
views
System.Drawing.Image from scratch [duplicate]
For testing purposes, I want to fill out a method like this one:
public static Image Image(int width, int height, Color color)
I would prefer to avoid involving physical files at all. I just want the ...
0
votes
0
answers
61
views
How to export merge multi image to one page two sides (2 by 5) in A4 size output in VB.NET
I'm Trying to export merge multi image to one page two sides (2 by 5) in A4 size output in VB.NET.
So the total image is 10 in 1 A4 page
Please Guide Me
Thanks
Imports System.IO
Public Class Form1
...
0
votes
0
answers
45
views
Saving a tag to an image file and loading it again all in memory
I can't seem to get the tag I'm adding to an image to stick once I save the image to a memory stream. Any idea how I can get that tag to end up in the imageCache byte array after I try and copy it to ...
0
votes
1
answer
177
views
Measure text width and height on .NET6+
Is there any possibility to measure a text width and height on .NET6+ cross-platform?
Something like:
var font = new Font("Arial", 16);
var gfx = Graphics.FromImage(new Bitmap(1, 1));
var ...
-2
votes
1
answer
125
views
Can't resolve System.Windows.Control.Image from being created instead of System.Drawing.Image
I'm working on moving a C# program into a WPF application and in order to export files from records I need to use the following code:
// Construct _imgfiles from the records
string _imgfile = ...
1
vote
0
answers
97
views
Implement wind barbs in C# Windows Forms
I am looking for the best way to draw or display wind barbs and I am using C# Windows Forms for my project.
In this project I tried to use ESRI weather fonts. But the challenge I had with it was that ...
0
votes
0
answers
74
views
Image.GetThumbnailImage rotates the image when it was taken using a mobile phone
I have the following extension methods to create thumbnails from a photo in a .NET Core 8 web application:
public static class ImageExtensions
{
public static Image ToThumbnail(this Image image, ...
1
vote
2
answers
685
views
How to save bitmap created using System.Drawing.Image back out to base64
I am trying to get a base64 image string into the system.drawing.image object (done) and then back out to base64 (not working), to include inline in an HTML e-mail, but am having difficulty.
The below ...
0
votes
0
answers
59
views
Drawing a cursor issues
I have been trying to make some basic 2D cnc like simulator, with some rectangle that is shaped by tools etc. I want to make cursor, so the user know where the current position of tool is.
But I don't ...
1
vote
0
answers
31
views
Compiling with Windows References on MacOS / Alternative to get Printer Settings?
Using C# and .NET Core 8, I am aware that System.Drawing.Printing is now firmly Windows only.
However this also means I have no access to these symbols/routines at design time or compile time from ...
0
votes
0
answers
48
views
Copying a rectangle image of transformed/rotated Graphics (Bitmap) into another transformed/rotated Graphics object
The functionality I want to achieve, is being able to copy a rectangle off of a part of image and pasting that part to another same dimension image in the same place. I want to use it to blur parts of ...
2
votes
0
answers
239
views
System.Drawing - DrawString text with emoji
I just want to create an image which contains some text. This text can contain emojis.
I'm using the "Segoe UI Emoji" font, and call:
var fontName = "Segoe UI Emoji";
var font = ...
0
votes
1
answer
116
views
Need Help How To Draw Both Arabic And English Words Char By Char
I'm trying to draw the same text from textBox to Panel char By Char For both Arabic & English with the same char size and position also style and color my code works perfectly if the text is ...
0
votes
2
answers
134
views
Using System.Drawing2D LinearGradientBrush to Fill Ellipse; Unexpected Results
Hello stackoverflow!
I am attempting to fill an ellipse with a LinearGradientBrush to "simulate" the dark and sun "sides" of a planet. Variable ovalCenter is the 3D vector (System....
-3
votes
1
answer
224
views
Draw arc in system.drawing C# [closed]
I have 2 points A(x1, y1) and B(x2, y2) on a circle and the angle between them alpha(example = 70 degree)
I would like to find the center of the circle and radius
I use System.Drawing namespace of C#
...
5
votes
1
answer
10k
views
Cross-platform System.Drawing.Bitmap in .NET 8?
We've been migrating a .NET 4.x application to .NET 8 and encountered a massive problem with System.Drawing.Bitmap. Our image processing was heavily dependent on graphic libraries, such as AForge. The ...
0
votes
0
answers
217
views
Network printers not showing in PrinterSettings.InstalledPrinters
I have a service running on a windows server 2019 VM that during setup will get a list of printers available using the below
List<string> printers = PrinterSettings.InstalledPrinters.Cast<...
3
votes
1
answer
118
views
Calc text width, JS vs Windows graphics
I have this code in JS:
function getTextWidth(text, font) {
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
context.font = font;
return ...
0
votes
0
answers
135
views
C# Custom Shape
How can you make this shape in C# using DrawArc And Draw Line?
Dashed Lines Is For Description Figure.
This image should be able to rotate around the center.
MaxRange And MinRange,The center point can ...
0
votes
0
answers
106
views
System.ArgumentException System.Drawing.Graphics.GetHdc()
I'm a low skilled hobby programmer and I wrote a program with a function to get the color of a pixel on the screen. The following Method is not wrote by myself. My Program is running for about 20 ...
1
vote
0
answers
43
views
Can't use System.Drawing in C# console application [duplicate]
I'm trying to make a program that would create images in C#. It would make some calculations, without any user interface, then export a bitmap image.
For that last part I tried to use System.Drawing ...
1
vote
1
answer
817
views
How to change the color of the tab each time its selected in a powershell Windows Form?
I'm looking to change the color of the tab on the currently active tabpage to make it stand out more.
I have set the DrawMode to OwnerDrawFixed and I was able to convert some c# code, found on another ...
2
votes
0
answers
1k
views
Replacement for System.Drawing.Image for Save, Load and convert to base64
Recently I started to get warnings such as:
CA1416: This call site is reachable on all platforms. 'Image' is only supported on: 'windows'.. When I looked for more information about it I found that ...
0
votes
1
answer
79
views
DrawPath doesn't return a correct shape when the corners are rounded
I'm trying to draw a rectangle with rounded corners. But when I print the layout there's a problem with the lines like the image below:
while the image that I need to print is this:
This is the part ...
0
votes
0
answers
82
views
Create Gradient Header in Image using C# Drawing Classes
I am trying to create an image in C# using the Drawing classes. The image has a grid and I want to create a gradient header similar to this image.
Can I get some guidance on how to do this? I tried ...
0
votes
1
answer
290
views
Why is C# graphics text antialiasing quality so poor with smaller font size?
I'm attempting to use the Bebas font to render text to a Bitmap in C#.
Consider the following code that loads a .png from the filesystem to render overlaying text:
public Bitmap CreateCard(...
0
votes
1
answer
66
views
Identical Inputs in SDK-style project fails to set Printer paper size but Framework-style project works
Using the System.Drawing.Printing namespace, to set the Paper Size of a document, the PaperSize PrintDocument.DefaultPageSettings.PaperSize { get; set; } property is used. When printing in an SDK-...
0
votes
0
answers
85
views
Make a gif looped
its possible create a loop gif. The code at the moment, add a label on gif but he repeat 30 times and them stopped...
string originalImgPath = @"..\35.gif";
System.Drawing.Image IMG = System....
0
votes
1
answer
364
views
How to combine two bitmaps vertically (using LockBits, and BitmapData)
I need a function in C# that returns merged bitmaps vertically. I want the resulting image to contain two bitmaps set one above the other. I don't have much experience with processing images in unsafe ...
0
votes
0
answers
217
views
WinForm How to use dirty rectangles to improve 2D drawing efficiency
I need to draw a lot of 2D graphics in the window. If I keep refreshing, it will lead to slow efficiency. I have learned about the drawing method with dirty rectangles. When using dirty rectangles for ...
1
vote
1
answer
221
views
Bitmap.Save is throwing Invalid Parameter
When passing a Bitmap to a method using thread.Start() and later calling bitmap.save() it throws the exception Invalid parameter when trying to save it to memory stream. I'm using a WPF project with ....
4
votes
1
answer
781
views
ImageSharp and System.Drawing Jpeg encoding differences
I'm reading a .png file as a byte array and trying to encode the image as a jpeg by using both System.Drawing (Microsoft.NETCore.App 6.0.8) and SixLabors ImageSharp (3.0.1).
I need the following ...
0
votes
1
answer
70
views
How to remove extra spacing between words in writing text by GraphicPath c#
Code:
Bitmap btm = new Bitmap(800, 400);
Graphics g = Graphics.FromImage(btm);
using (GraphicsPath gp = new GraphicsPath())
using (Pen outline = new Pen(Brushes.Green, 2)
{ LineJoin = LineJoin.Round })...
0
votes
0
answers
188
views
Resizing animated Gifs in PowerShell
I'm trying to write a helper function in PowerShell that takes an image and resizes it.
This is easy enough for static images, but I'm having trouble with Gifs. If I use the same logic on animated ...
0
votes
0
answers
496
views
C# ASP.NET FileStreamResult doesn't send or stuck after using System.Drawing and System.Windows.Forms
I am using ASP.NET FileStreamResult to send back a file as a response to the user.
It works fine on sending any file, but after calling some functions using System.Drawing to generate some files, it ...
0
votes
1
answer
221
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....
0
votes
0
answers
72
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 ...
4
votes
1
answer
2k
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
232
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
97
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
611
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
1k
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
69
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 ...
1
vote
1
answer
426
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 ...
1
vote
1
answer
3k
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 ...
1
vote
1
answer
10k
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 ...
2
votes
0
answers
1k
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 ...