请问:我现在有一个10×10的蓝色图片。我用了四种方法来进行了拉伸操作,但都是失败的,因为拉伸后图片的颜色会渐变为黑色。不知道为什么?谁能告诉我怎么才能不使图片的底色发生颜色变化。是不是和图片的文件类型有关吗?谢谢。
假如图片的文件名为a.png(10 ×10)
方法1:Graphics graphics(hdc);
Image image(L"a.png");
graphics.DrawImage(&image, 0, 0, 100, 100);
方法2:Graphics graphics(hdc);
Image image(L"a.png");
Rect rect(100, 100, image.GetWidth(), image.GetHeight());
graphics.DrawImage(&image, rect);
方法3:Graphics graphics(hdc);
Image image(L"a.png");
Point points[] = { Point(0, 0), Point(100, 0), Point(0, 100)};
graphics.DrawImage(&image, points, 3);
方法4:Graphics graphics(hdc);
Image image(L"a.png");
Point points[] = { Point(0, 0), Point(image.GetWidth(), 0), Point(0, image.GetHeight())};
Matrix matrix(1,0,0,1,0,0);
matrix.Scale(10, 10); // X 和 Y 方向分别乘以比例因子
matrix.TransformPoints(points, 3); // 用该矩阵转换points
graphics.DrawImage(&image, points, 3);
假如图片的文件名为a.png(10 ×10)
方法1:Graphics graphics(hdc);
Image image(L"a.png");
graphics.DrawImage(&image, 0, 0, 100, 100);
方法2:Graphics graphics(hdc);
Image image(L"a.png");
Rect rect(100, 100, image.GetWidth(), image.GetHeight());
graphics.DrawImage(&image, rect);
方法3:Graphics graphics(hdc);
Image image(L"a.png");
Point points[] = { Point(0, 0), Point(100, 0), Point(0, 100)};
graphics.DrawImage(&image, points, 3);
方法4:Graphics graphics(hdc);
Image image(L"a.png");
Point points[] = { Point(0, 0), Point(image.GetWidth(), 0), Point(0, image.GetHeight())};
Matrix matrix(1,0,0,1,0,0);
matrix.Scale(10, 10); // X 和 Y 方向分别乘以比例因子
matrix.TransformPoints(points, 3); // 用该矩阵转换points
graphics.DrawImage(&image, points, 3);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货