Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Cleaner Pictures in PictureBox

I've had this issue for a while.
When I tried to use icons/pictures on windows forms, they'd often have pretty pixelated edges.
Here's a neat way to fix it using a custom component which allows you to use the base PictureBox with some custom properties.

Code
public class CPictureBox : PictureBox
{
    public InterpolationMode InterpolationMode { get; set; }
    public PixelOffsetMode PixelOffsetMode { get; set; }

    protected override void OnPaint(PaintEventArgs paintEventArgs)
    {
        paintEventArgs.Graphics.InterpolationMode = InterpolationMode;
        paintEventArgs.Graphics.PixelOffsetMode = PixelOffsetMode;
        base.OnPaint(paintEventArgs);
    }
}
For best results:
Code
InterpolationMode: HighQualityBilinear
PixelOffsetMode: HighQuality

Pictures (Click to View)
Concept taken from here, I basically just added the PixelOffsetMode and figured some people on here might find it useful.
Good contribution, I'm sure this will help a lot of people
[Image: Syr3DlV.png]
Another good way of displaying clear pictures on a picture box is to get a picture with a size multiplier above and resize it to the picture box size.

Example: Picturebox is 480p in size, you get a 720p or 1080p picture and feed it to the picture box and then adjust to the picturebox size, this has the disadvantage of you having to use some extra space, but a couple of MB's in a normal app is pratically nothing.

I'm not saying your way of doing it isn't good OP.
(Nov 7, 2017 06:33 AM)He B TeMy Wrote:  Another good way of displaying clear pictures on a picture box is to get a picture with a size multiplier above and resize it to the picture box size.

Example: Picturebox is 480p in size, you get a 720p or 1080p picture and feed it to the picture box and then adjust to the picturebox size, this has the disadvantage of you having to use some extra space, but a couple of MB's in a normal app is pratically nothing.

I'm not saying your way of doing it isn't good OP.

Lol resolution does not describe the size of a box though. But this is a fair point nonetheless.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
Making the picturebox sizemode to zoom does the same thing right?
This is really useful, thanks. I've experienced this same issue before.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by ShapelessSep 27, 2019 12:15 PM 16 614 Sep 27, 2019 12:15 PM
Last Post: 0xDEAD10CC
[C] by The KhanJul 10, 2018 12:58 AM 4 144 Jul 10, 2018 12:58 AM
Last Post: The Khan
[C#] by The KhanJul 10, 2018 12:50 AM 0 303 Jul 10, 2018 12:50 AM
Last Post: The Khan