为什么 Graphics::DrawImage 没有按预期拉伸图像?
我正在制作一个重载的TableLayoutPanel
它绘制了一些奇特的边框,但由于某种原因,对 Graphics::DrawImage
的调用无法按预期工作。当我拉伸它时,它似乎淡出了我的 1x10 像素源图像:
这是进行渲染的函数:
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));
}
}
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));
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是使用极端放大倍率时插值的副作用。你需要这样的东西:
It is a side-effect of interpolation when you use extreme magnification. You'll need something like this: