Questions tagged [system.drawing.imaging]

80 questions
3
votes
2 answers

How to avoid useless white border in resized PNG with transparent background?

I have a folder containing about 2500 PNG images, with no transparency. Every image is about 500 x 500 (some are 491 x 433, others 511 x 499 etc). I want to programatically downsize every image to 10% of its original size, and to set the white…
alex
  • 1,228
  • 1
  • 16
  • 38
3
votes
4 answers

Programmatically replace transparent regions in an image with white fill?

I've got a PNG image that I'm operating on via the System.Drawing API in .NET. It has large transparent regions, and I would like to replace the transparent regions with white fill--so that there are no transparent regions in the image. Easy…
Josh
  • 7,232
  • 8
  • 48
  • 75
3
votes
1 answer

Html To Image Using NReco.ImageGenerator : C#

Introduction I am working with the functionality where we can convert "html" to image.For image creation, i use "Image" function(of System.Drawing). Functionality working fine(including html styles etc) except for one thing i will describe later …
3
votes
1 answer

Error: The calling thread cannot access this object because a different thread owns it

I get this error. Here is the code: Image image; BitmapImage BmpImg; MemoryStream ms; public void Convert() { ms = new MemoryStream(); image.Save(ms, ImageFormat.Jpeg); BmpImg = new BitmapImage(); …
Vinshi
  • 313
  • 2
  • 7
  • 27
2
votes
2 answers

Reading/preserving a PixelFormat.Format48bppRgb PNG Bitmap in .NET?

I've been able to create a Format48bppRgb .PNG file (from some internal HDR data) using the the following C# code: Bitmap bmp16 = new Bitmap(_viewer.Width, _viewer.Height,…
holtavolt
  • 4,378
  • 1
  • 26
  • 40
2
votes
2 answers

Is it a Bitmap or MetaFile?

Given a Stream that I know will be a picture, is there a way to programmatically determine if it is a Bitmap or a MetaFile when pulled from Image.FromStream(mystream)? Like a flag or something. Environment: .NET, System.Drawing, C#/VB
Todd Main
  • 28,951
  • 11
  • 82
  • 146
2
votes
1 answer

Setting the value of a System::Drawing::Imaging::PropertyItem^

I would like to give my Bitmap a PropertyItem value but i am not really sure how to give it a System::String^ value. System::Drawing::Imaging::PropertyItem^ propItem = gcnew System::Drawing::Imaging::PropertyItem; System::String^ newValue = gcnew…
Chris B
  • 47
  • 3
2
votes
0 answers

How to change colors of EMF+ image in C#

I'm trying to develop a special kind of heatmap, where the color of a marker depends on the value of some calculated variables. What I need to do is change the color of my existing EMF+-Image. The following code works like a charm when using png or…
Thomas
  • 81
  • 3
2
votes
1 answer

Image.Save() on MemoryBmp to TIFF with EncoderParams - How?

I have an application that allows a user to define a region of an image and save that region to file. I have run up against a snag that I can't sort out. The Bitmap that I create to paint the selected region onto is stuck with an ImageFormat of…
scubasteve
  • 2,718
  • 4
  • 38
  • 49
2
votes
2 answers

How to serve up image from type System.Drawing.Bitmap ( tag?)

I am sending a bitmap to a View in ASP.NET MVC. I have a property in my ViewModel: public Bitmap TemplateImage { get; set; } In my View, I want to be able to render that Bitmap image but I can't figure out how to do it.
2
votes
4 answers

File extension from System.Drawing.Image

I'm writing a method that needs to save a System.Drawing.Image to a file. Without knowing the original file the Image was created from, is there anyway to determine what file extension it should have? The best solution I've come up with is to use a…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
2
votes
1 answer

GIF to PNGs: only first frame extracted

I am trying to extract the individual frames of an animated gif in my c# programm. It creates a png for each frame - that works just fine, however they are just a bunch of copies of the first frame. What did I do wrong? Image img =…
000000000000000000000
  • 1,467
  • 1
  • 19
  • 38
2
votes
0 answers

How can I implement white out/black out functionality using ColorMatrix in ImageAttributes

I have white out/black out (lighting designer features) implemented on a Color using the code below. Instead of iterating through colors in a bitmap I would like to implement this using a ColorMatrix on ImageAttributes. I have the blackout part…
2
votes
0 answers

Imaging.CreateBitmapSourceFromHIcon throws COMException

I use Imaging.CreateBitmapSourceFromHIcon method to convert Icon to BitmapSource: private static System.Windows.Media.ImageSource loadWpfImageSource(Icon icon, Size size) { if (icon != null) { return…
Artem Kachanovskyi
  • 1,839
  • 2
  • 18
  • 27
1
vote
1 answer

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. Currently I have an…