2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2000 The LyX Team.
9 * ================================================= */
19 #include "boost/utility.hpp"
24 /** ImageLoader is a base class for all image loaders. An ImageLoader instance is
25 * platform dependent, and knows how to load some image formats into a memory
26 * representation (LyXImage).
28 * It may do the image loading asynchronously.
30 * @Author Baruch Even, <baruch.even@writeme.com>
32 class ImageLoader : public noncopyable {
34 /// Errors that can be returned from this class.
37 ImageFormatUnknown, // This loader doesn't know how to load this file.
38 NoFile, // File doesn't exists.
39 ErrorWhileLoading, // Unknown error when loading.
42 /// A list of supported formats.
43 typedef vector<string> FormatList;
48 virtual ~ImageLoader();
50 /// Start loading the image file.
51 ImageLoader::Result loadImage(string const & filename);
53 /// Get the last rendered pixmap. Returns 0 if no image is ready.
54 LyXImage * getImage() const { return image_; };
56 /// Return the list of loadable formats.
57 virtual FormatList const loadableFormats() const;
60 /// Verify that the file is one that we can handle.
61 virtual bool isImageFormatOK(string const & filename) const = 0;
63 /// Do the actual image loading.
64 virtual Result runImageLoader(string const & filename) = 0;
66 /// Set the image that was loaded.
67 void setImage(LyXImage * image);
70 /// Free the loaded image.