C++ SDL framework无法显示小于20x20像素的BMP文件?

C++ SDL framework无法显示小于20x20像素的BMP文件?,c++,limit,sdl,bmp,C++,Limit,Sdl,Bmp,有人知道SDL framework中的BMP文件是否有显示它们的最小大小限制吗? 我问你这个问题是因为我尝试过,但无法正确显示小于20x20像素的BMP文件。(我使用SDL for C++) 代码: bool successCondition = false; if (SDL_Init(SDL_INIT_VIDEO) != 0) { printf("Unable to initialize SDL: %s\n", SDL_GetError());

有人知道SDL framework中的BMP文件是否有显示它们的最小大小限制吗?
我问你这个问题是因为我尝试过,但无法正确显示小于20x20像素的BMP文件。(我使用SDL for C++)

代码:

    bool successCondition = false;  
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return 1;
    }
    atexit(SDL_Quit);

    SDL_Surface *screen;

    screen = SDL_SetVideoMode(640, 480, 24, SDL_DOUBLEBUF);
    if (screen == NULL) {
        printf("Unable to set video mode: %s\n", SDL_GetError());
        return 1;
    }

    // nueva imagen
    Image* imgSmile = new Image("Images/smile.bmp");

    SDL_Rect src, dest;
    src.x = 0;
    src.y = 0;
    src.w = imgSmile->getWidth();
    src.h = imgSmile->getHeight();
    dest.x = 50;
    dest.y = 20;
    dest.w = imgSmile->getWidth();
    dest.h = imgSmile->getHeight();
    SDL_BlitSurface(imgSmile->getSDLSurface(), &src, screen, &dest);
    SDL_Flip(screen);

    // nueva imagen
    Image* imgSmileRe = new Image("Images/smile.bmp");


    // Achico la imagen
    imgSmileRe->resize(10, 10);

    // Pego la imagen en la pantalla
    src.x = 0;
    src.y = 0;
    src.w = imgSmileRe->getWidth();
    src.h = imgSmileRe->getHeight();
    dest.x = 100;
    dest.y = 20;
    dest.w = imgSmileRe->getWidth();
    dest.h = imgSmileRe->getHeight();
    SDL_BlitSurface(imgSmileRe->getSDLSurface(), &src, screen, &dest);
    SDL_Flip(screen);


    //esperar para cerrar
    SDL_Event e;
    bool running = true;

    while(running) 
    {
        while(SDL_PollEvent(&e)) 
        {
            switch(e.type)
            {
                case SDL_QUIT:
                    running = false;
                    SDL_Quit();
                    break;
            }
        }
    }

    // libero memoria
    free(imgSmile);
    free(imgSmileRe);

    successCondition = true;

    return successCondition;

}  
以及调整大小的代码:

void Image::resize(int newWidth, int newHeight)
{
    int widthSrc    = this->getWidth();
    int heightSrc   = this->getHeight();

    // Empty new image
    Image* temp = new Image(newWidth, newHeight);

    int posXDst = 0;
    int posYDst = 0;

    for(int posYSrc = 0; posYSrc < heightSrc ; posYSrc++){


        for(int posXSrc = 0; posXSrc < widthSrc; posXSrc++){

            posXDst = (posXSrc * newWidth) / widthSrc;
            posYDst = (posYSrc * newHeight) / heightSrc;

            Uint32 pixelImg = this->getPixel(posXSrc, posYSrc);


            if( posXSrc > 0 && posYSrc > 0 && newWidth > widthSrc && newHeight > heightSrc ){

                int fromY = (((posYSrc-1) * newHeight) / heightSrc);
                int fromX = (((posXSrc-1) * newWidth) / widthSrc);

                // interpolacion interna
                for (int y = fromY; y <= posYDst; y++){
                    for (int x = fromX; x <= posXDst; x++){

                        // pixel y posicion superior izquierdo
                        Uint32 pixelSI = this->getPixel(posXSrc-1, posYSrc-1);
                        int xSI = ((posXSrc-1) * newWidth) / widthSrc;
                        int ySI = ((posYSrc-1) * newHeight) / heightSrc;
                        // pixel y posicion superior derecho
                        Uint32 pixelSD = this->getPixel(posXSrc, posYSrc-1);
                        int xSD = (posXSrc * newWidth) / widthSrc;
                        int ySD = ((posYSrc-1) * newHeight) / heightSrc;
                        // pixel y posicion inferior izquierdo
                        Uint32 pixelII = this->getPixel(posXSrc-1, posYSrc);
                        int xII = ((posXSrc-1) * newWidth) / widthSrc;
                        int yII = (posYSrc * newHeight) / heightSrc;

                        // obtengo el pixel interpolado
                        Uint32 interpolatedPixel = this->getInterpolatedPixel( pixelSI, xSI, ySI, 
                                                                            pixelSD, xSD, ySD, 
                                                                            pixelII, xII, yII, 
                                                                            pixelImg, posXDst, posYDst, 
                                                                            x, y, temp->getFormat());

                        // coloco el pixel en la imagen destino
                        temp->putPixel( interpolatedPixel, x, y );
                    }
                }
            }

            // Pongo el pixel en las nuevas coordenadas
            temp->putPixel( pixelImg, posXDst, posYDst);
        }
    }

    this->copy(*temp);
    free(temp);
} 
void Image::resize(int-newWidth,int-newHeight)
{
int-widthSrc=this->getWidth();
int heightSrc=this->getHeight();
//清空新图像
图像*温度=新图像(新宽度、新高度);
int posXDst=0;
int-posYDst=0;
对于(int-posYSrc=0;posYSrcgetPixel(posXSrc,posYSrc);
if(posXSrc>0&&posYSrc>0&&newWidth>widthSrc&&newHeight>heightSrc){
int fromY=((posYSrc-1)*新高度)/高度src);
int fromX=((posXSrc-1)*newWidth)/widthSrc);
//内插层
for(int y=fromY;y getPixel(posXSrc,posYSrc-1);
int xSD=(posXSrc*newWidth)/widthSrc;
int ySD=((posYSrc-1)*新高度)/高度SRC;
//像素y位置
Uint32 pixelII=此->获取像素(posXSrc-1,posYSrc);
int xII=((posXSrc-1)*新宽度)/widthSrc;
int yII=(posYSrc*新高度)/高度src;
//obtengo el像素插值
Uint32 interpolatedPixel=此->获取interpolatedPixel(pixelSI、xSI、ySI、,
像素SD、xSD、ySD、,
pixelII,xII,yII,
像素图像,posXDst,posYDst,
x、 y,temp->getFormat());
//coloco el pixel en la imagen destino
temp->putPixel(插值像素,x,y);
}
}
}
//新埃瓦斯库德纳达斯酒店
temp->putPixel(像素img、posXDst、posYDst);
}
}
此->复制(*temp);
免费(临时);
} 
很抱歉西班牙的评论。
我使用的是windows xp/7,图像是一张笑脸,采用约20x20像素的24位BMP文件。

理论上,BMP大小没有限制(就SDL而言).

您运行的是什么操作系统?您是如何加载BMP的?代码是什么?您的调整大小功能可能有问题。如果您在一个函数中替换所有源到目标的Blitch,会更好。这是真的,我们所做的错误是我们没有考虑用于调整大小的图像的pítch将图像中的位对齐。