Surface Class Loading a BMP

The Partridge Family were neither partridges nor a family. Discuss.
egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Surface Class Loading a BMP

Post by egizz983 » October 8th, 2016, 7:03 am

Luis what about my first question should i make it pointer or not ? cuz if i do pointer i dont able to read bmp anymore

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Surface Class Loading a BMP

Post by LuisR14 » October 8th, 2016, 10:03 pm

the problem with the pointer is that you have to allocate it

Code: Select all

class Surface
{
public:
    Surface(std::string filename)
    : sprite( new std::vector<Color>() )
    {	
        LoadBMP(filename, *sprite,width,height);
    }
    ~Surface()
    {	
        sprite->clear();
        delete sprite;
    }
    void Draw(int xoff ,int yoff , int tr,int tg,int tb,Graphics &gfx)
    {
        gfx.DrawSprite(xoff, yoff, width, height, *sprite, tr, tg, tb);
    }
private:
    unsigned int width;
    unsigned int height;
    std::vector<Color>* sprite;
};
so it's best the way you have it now
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply