gdi+

How to deal with color loss on GDI+ Image Resize?

Hello All, I am resizing images with C#/GDI+ using the following routing bmpOut = new Bitmap(lnNewWidth, lnNewHeight); Graphics g = Graphics.FromImage(bmpOut); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeigh...

Gdiplus mask image from another image

Is there a way to manipulate alpha of an image using alpha from another image? Suppose I have a Image and I want to alter its alpha starting opaque at left and totally transparent at right, currently I draw another image with LinearGradientBrush and set alpha of orginal image from second image by looping pixel by pixel, is there another...

C# : GDI+ Image cropping

I have an image .I want to crop 10 px from left and 10px from right of the image.I used the below code to do so string oldImagePath="D:\\RD\\dotnet\\Images\\photo1.jpg"; Bitmap myOriginalImage = (Bitmap)Bitmap.FromFile(oldImagePath); int newWidth = myOriginalImage.Width; int newHeight = myOriginalImage.Height; Rectan...

Saving JPEG screenshot as a BYTE buffer in C

In one of my previous questions I asked how to take a screenshot and save it as JPEG without the use of GDI+ due to the constrains of having to use only C. At the end I answered the question myself with the help of of some of the comments there. Using a very terse C version of GDI+ (loaded at runtime) i can take a screenshot and save it...

C# :GDI+ : OverWriting an Image using Save Method of Bitmap

I have an ASP.NET C# page where i am resizing the images in a folder .I am using GDI+ to do this.I want to resize the images and replace with the old images.So when i am trying to save with the existing name ,Save method is throwing an error .But if i give a different name it is getting saved.But i want to have the same file name for the...

A generic error occurred in GDI+, JPEG Image to MemoryStream

Hi, This seems to be a bit of an infamous error all over the web. So much so that I have been unable to find an answer to my problem as my scenario doesn't fit. An exception gets thrown when I save the image to the stream. Weirdly this works perfectly with a png but gives the above error with jpg and gif which is rather confusing. Mos...

Ultra fast drawing in DotNET

Initial tests indicate that GDI+ (writing in VB.NET) is not fast enough for my purposes. My application needs to be able to draw tens of thousands of particles (coloured circles, very preferably anti-aliased) in a full screen resolution at 20+ frames per second. I'm hesitant to step away from GDI+ since I also require many of the other ...

How to write to a (Bitmap?) image buffer for faster GDI+ displays?

Using C++ and .net I have a stream of data I want to display as a scrolling image. Each time I get some new data I want to add it as a new row (128x1 pixels) and scroll the previous contents to one side. My first stab at the problem involved rendering the entire data set each time I got a new row. This worked, but was far too slow, so I...

How do I use the GDI+ blur effect on a .NET Bitmap?

I need to apply a blur to a System.Drawing.Bitmap. The classes in System.Drawing are supposed to be wrappers around GDI+, so I'd I use the GDI+ Blur effect. Is this possible, and if so, how? Edit: I don't want to know how to write my own Blur effect, I want to know how to use the built-in GDI+ one. ...

GDI+ Exception when using DrawString()

I'm getting an error when trying to create a barcode image using a barcode font. This is happening in production but not in dev. The method creating the barcode is: /// <summary> /// Create a barcode image by writing out a string using a barcode font and save it /// </summary> /// <param name="barcodeText">The text string of the barco...

C#, GDI+ - Why are my rectangles truncated?

When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap b = new Bitmap(300, 400); using (Graphics g = Graphics.FromImage(b)) { g.FillRectangle(Brushes.Black, new Rectangle(0, 0, 300, 400)); } b.RotateFlip(RotateFlipType.Rotate90FlipNone);...

Looking for a faster-than-GDI solution for rendering dynamic data plots

I've written a simple GDI-based data plotter using C++/CLI but it's not particularly fast (some basic profiling indicates it's the rendering to screen that's the problem). Is there any way to enable hardware acceleration for a UserControl or is there a .net interface for direct3D? ...or are there some other options I could consider. We...

SSRS 2008 Export Report to Image Only Exports First Page

Ok, so i am working on exporting my SSRS 2008 Reports to an image. What I would like to do is Export each individual page as an image. From my code, I can only get it to export the first page of the report. Any help would greatly be appreciated. Dim warnings As Microsoft.Reporting.WebForms.Warning() Dim streamids As String() ...

Performance problem with large number of ColorMaps with ImageAttributes.SetRemapTable

I'm dynamically mapping colours in an image that has alpha transparency in it to another (smaller set) of colours. I've got code like: var mappings = new List<ColorMap>(); foreach(var color in mapcolours) { // Add mappings for all alpha values of the mask colour for(int i = 0; i < 256; i++) { var cm = new ColorMap()...

Rotate Hue using ImageAttributes in C#

How can I rotate the hue of an image using GDI+'s ImageAttributes (and presumably ColorMatrix)? Note that I want to rotate the hue, not tint the image. EDIT: By rotating the hue, I mean that each color in the image should be shifted to a different color, as opposed to making the entire image a shade of one color. For example, Origina...

Drawing a transparent button in C# Winforms

I'm trying to create a transparent button in C# (.NET 3.5 SP1) to use in my WinForms application. I've tried everything to get the button to be transparent (it should show the gradient background underneath the button) but it's just not working. Here is the code I'm using: public class ImageButton : ButtonBase, IButtonControl { pub...

Get the size of jpeg from memory (converted using GDI++)

Hello, This is my first post here. I have a problem. I need to take a sceenshot of the desktop, convert it to jpeg, store it in a buffer and then manipulate it and send it over the internet. I have written the code for doing this with GetDC....and GDI+ for converting the HBITMAP to jpeg. The problem I am having now is that I don't know...

GDI+ Image Conversion From Metafile to JPEG/GIF Results in Black Background

So i am converting a metafile (EMF to be exact) to a jpeg or gif (doesn't matter as long as it's compatible with browsers) and when I do the conversion, all of the transparent pixels turn black. I have no idea how to do this in GDI+ but here is the method I am using to save the file: Dim Img As System.Drawing.Imaging.Metafile = New Sys...

Is GDI+ just a layer on top of GDI, or something new?

When GDI+ came out, I remember all the brouhaha about how it was the "new, faster, better" way to display stuff in Windows. But everytime I looked at it, it seemed to me that it was really just a COM wrapper around GDI. Is that true? Or is GDI+ really an independent graphical library that simply shares some paradigms with GDI? Personal...

System.Drawing Error: Can or Cannot it be used in an ASP.Net application

We are using System.Drawing in and application to manipulate images in a web application (rotate, flip, etc). For the last month we have been getting the following error very sporadically. "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Based on the MSDN Library it appears that ...