I'm having problems enlarging images using the Graphics object. The quality of the enlarged images is bad. I get the best results by setting the interpolation mode to nearest neighbor and pixel offset mode to high quality. Even then, the image is grainy. Here's an example: protected override void OnPaint(PaintEventArgs e) { if(this.image != null) { RectangleF source = new RectangleF(0f,0f,0f,0f) RectangleF dest = new RectangleF(0f,0f,0f,0f) dest.X = e.ClipRectangle.X; dest.Y = e.ClipRectangle.Y; dest.Width = e.ClipRectangle.Width; dest.Height = e.ClipRectangle.Height; source.X = dest.X / zoom; source.Y = dest.Y / zoom; source.Width = dest.Width / zoom; source.Height = dest.Height / zoom; e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; e.Graphics.DrawImage(image, dest, source, GraphicsUnit.Pixel); } if(deleg != null) deleg(this, e); base.OnPaint(e); } Basically, what I'm looking for is something like a simple pixel resize. I've tried doing this manually, but with bigger images it takes a lot of resources. Any ideas?
Kryal
Posts
-
Image enlarging quality -
Functions and pointersHow can I get the unmanaged pointer of a managed method in C# so that I can store it in an integer within unmanaged memory? Also, how can I wrap an object around a pointer, with In/Out capabilities? It sounds kind of complicated, but I believe it is possible somehow. I'm trying to use a DLL in my program, which creates and uses a custom structure (in this case in the unmanaged memory). Luckily, there is a function in the DLL which allows me to retrieve the address of the structure, and I know all of the members in that structure through documentation. The part that trips me up is that the structure stores pointers to functions, and in order to use the DLL the way I would like, I want to change those pointers to my managed C# methods. As for the structure itself, I would like to wrap a managed structure around a pointer so that I can access the fields within it as well as write to those fields, kind of like a two-way link between the managed and unmanaged memory... I only wish there were an easier way to explain all this. Does anybody know what I'm talking about?
-
Multi-platform C#?Is it possible to run a C# .NET program on Linux or MacOS? I read something about compiling a Portable Executable file, but I know nothing about it.
-
Question about reflection...I've read up on Relection.Emit and its uses and am amazed at the flexability. But, I'm wondering if it will do more. First, I declare Dynamic Assembly using the current running assembly. I can now add members to the assembly and even switch out a method body using the MethodRental class! But, is it possible to remove members from an assembly or class? What about adding or changing members to an exising member in the assembly? Is this in any way possible, or would the entire assembly or module have to be created from scratch?
-
Sending commands between Windows applications?I want my program to be able to find a specified window, activate it, and send it keyboard commands. Kind of like a macro program. How would I code this?