File 将bmp文件放大n倍
好了,伙计们,我正在研究一种放大bmp文件的方法,但我对如何进行有点困惑。这就是我认为放大的方式: 假设我们有bmp文件:File 将bmp文件放大n倍,file,bmp,File,Bmp,好了,伙计们,我正在研究一种放大bmp文件的方法,但我对如何进行有点困惑。这就是我认为放大的方式: 假设我们有bmp文件: 0 1 2 3 4 5 一个3x2 2D阵列,假设我们想将这幅图像放大2倍,那么新图像看起来像这样: 0 0 1 1 2 2 0 0 1 1 2 2 3 3 4 4 5 5 3 3 4 4 5 5 我对此的看法是正确的,还是以不同的方式工作? 谢谢,我只需要了解它是如何工作的,才能写下一个算法。我基本上把这种图像大小调整方法称为:“暴力大小调整”或“图像缩放” 尺寸计算
0 1 2
3 4 5
一个3x2 2D阵列,假设我们想将这幅图像放大2倍,那么新图像看起来像这样:
0 0 1 1 2 2
0 0 1 1 2 2
3 3 4 4 5 5
3 3 4 4 5 5
我对此的看法是正确的,还是以不同的方式工作?谢谢,我只需要了解它是如何工作的,才能写下一个算法。我基本上把这种图像大小调整方法称为:“暴力大小调整”或“图像缩放”
比如说:AA=3、AB=2、AC=6和BA=6、BB=4、BC=24和scaleX=2、scaleY=2
int ptotal=AC//or=AA*AB
对于(pcount=0;pcount
int set\u rect\u BMP(BMP*BMP,int x,int y,int w,int h,int r,int g,int b){
int i,j;
对于(i=y;i
算法图:
如有需要,将提供进一步解释;) 请在此处查看有关维基百科的更多信息:
int ptotal = AC; //or = AA * AB
for (pcount = 0; pcount < ptotal; ++pcount)
{
img_x = (pcount%(AA))*scaleX;
if ((pcount%(scaleX))==0)
img_y += scaleY;
set_rect_BMP(bmp,img_x,img_y,scaleX,scaleY,r,g,b);
}
int set_rect_BMP(BMP* bmp, int x, int y, int w, int h, int r, int g, int b) {
int i, j;
for (i = y; i < h+y; ++i)
{
for (j = x; j < w+x; ++j)
{
BMP_SetPixelRGB( bmp, j, i, r, g, b );
//BMP_SetPixelRGB( bmp, the x coord, the y coord, red, green, blue );
}
}
}