I'm making an overloaded TableLayoutPanel which draws some fancy borders, but for some reason the call to Graphics::DrawImage isn't working as expected. It seems to fade out my 1x10 pixel source image when I stretch it:

This is the function which does the rendering:
void GTableLayoutPanel::RenderSides(Graphics^ g, array<Drawing::Image^>^ sideImages)
{
if( sideImages )
{
if( sideImages->Length < 4 )
{
throw gcnew System::ArgumentException(String::Format("Not enough images supplied to render sides (expected 4 but only got {0})", sideImages->Length));
}
int borderSize = sideImages[0]->Height;
g->DrawImage(sideImages[0], Rectangle(borderSize, 0, this->Width-borderSize*2, borderSize));
g->DrawImage(sideImages[1], Rectangle(this->Width-borderSize, borderSize, borderSize, this->Height-borderSize*2));
g->DrawImage(sideImages[2], Rectangle(borderSize, this->Height-borderSize, this->Width-borderSize*2, borderSize));
g->DrawImage(sideImages[3], Rectangle(0, borderSize, borderSize, this->Height-borderSize*2));
}
}
It is a side-effect of interpolation when you use extreme magnification. You'll need something like this:
g->InterpolationMode = System::Drawing::Drawing2D::InterpolationMode::NearestNeighbor;
g->PixelOffsetMode = System::Drawing::Drawing2D::PixelOffsetMode::None;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With