Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4603352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:08:05+00:00 2026-05-22T00:08:05+00:00

Does anybody know if there is a min. size limit for BMP files in

  • 0

Does anybody know if there is a min. size limit for BMP files in SDL framework to show them?
I’m asking you this because I tried but can not show correctly BMP files that are less than 20×20 pixels.(I’m using SDL for C++).

Code:

    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;

}  

And the code for resize:

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);
} 

Sorry for the spanish comments.
I’m using windows xp/ 7 the image is a smiley face in 24bits BMP file aprox 20×20 pixels.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:08:06+00:00Added an answer on May 22, 2026 at 12:08 am

    Theoreticaly, there is no limit for the BMP size (as far as SDL is concerned).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know if there is a way to create an SQLite database based
Does anybody know if there is a way to make autocompletion work in MySQL
Does anybody know if there is a way using java to pass all the
Does anybody know if there is a way to understand what users are doing
Does anybody know if there is any library of managed wrappers that allows me
Does anybody know of a library or piece of software out there that will
does anybody know how to make a numericupdown control for asp. There's one for
Does anybody out there know how to use Ninject with a WCF webHttp Service
Does anybody know a good library for writing SVG files in Android? I've looked
Does anybody know what the theme parts WP_FRAMELEFT , WP_SMALLFRAMERIGHT etc are used for?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.