开发者

Typecasting two user-defined objects in C++ -- possible?

I am trying to get a C++ code base that works on a desktop to run on an Android phone. The code does stuff with images and presently uses a user-defined class called CqByteImage to interface with images. The NDK interfaces with the camera using an IplImage object.

Now, for me to make minimal changes, I wonder if there is an easy to type cast the IplImage as the other?

If not, my only solution seems to be to re-wr开发者_C百科ite the functions to accept IplImage now - which can be tricky since I have over 30.h/cpp files.

Suggestions welcome. I can post clarifications if my questions are vague.

Help much appreciated, M


You won't want to do this by casting or re-writing the functions.

You'll want to create a method that creates a CqByteImage from an IplImage, either by pulling all the data from the IplImage or by implementing the methods in CqByteImage in terms of the methods in IplImage.


Have you considered making a wrapper to use your IplImages as CqByteImages? See http://en.wikipedia.org/wiki/Adapter_pattern

If the images have a compatible internal representation, this might even be very efficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜