Sign in to follow this  
darenking

How do I return a pointer to a BITMAP (C++ using Allegro)

Recommended Posts

darenking    122
Hello! I am writing a class to control bitmaps in C++ using Allegro. I want to add a method that returns a pointer (or something?) to the bitmap, so that another class or my main() function can draw the bitmap to the screen buffer. I have tried it like this (below), but it doesn't work so clearly it is wrong! ____ //picture.h class Picture { private: BITMAP *m_Image; // <- here is my bitmap public: BITMAP* ImageGet(); // <- and here is my lame attempt at a method that returns a pointer to it }; ____ //picture.cpp BITMAP* Picture::ImageGet(); { return m_Image; } ____ Any ideas?

Share this post


Link to post
Share on other sites
matthughson    588
Looks right to me. What exactly is the problem?

Perhaps it is your use of the function that is causing problems. Post that if you can.

Matt Hughson

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Maybe change

BITMAP *m_Image;

to

BITMAP m_Image;

AND

BITMAP* ImageGet()

to

BITMAP& ImageGet()

Share this post


Link to post
Share on other sites
darenking    122
OK, so if I have this:

private:
BITMAP m_Image;

Does that mean that the entire bitmap is stored inside the instance of the class, rather than a pointer to the bitmap?

Can you even do that in Allegro? I don't think you can, but I'm not sure.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this