*/
// INTERNAL INCLUDES
-#include <dali/public-api/images/nine-patch-image.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
+#include <dali/devel-api/images/nine-patch-image.h>
+#include <dali/internal/event/images/resource-image-impl.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
namespace Dali
{
class NinePatchImage;
typedef IntrusivePtr<NinePatchImage> NinePatchImagePtr;
-class ResourceClient;
-class ResourceManager;
-
namespace SceneGraph
{
class UpdateManager;
* It's image data has a border which determines stretch and fill areas
* Its pixel buffer data is loaded synchronously from file.
*/
-class NinePatchImage : public Image
+class NinePatchImage : public ResourceImage
{
public:
+ typedef Dali::Vector< Uint16Pair > StretchRanges;
+
+public:
/**
* Create a new NinePatchImage.
* Also a pixel buffer for image data is allocated.
* Dali has ownership of the buffer.
* @param [in] filename File to load synchronously into buffer
- * @param [in] attributes Image attributes of the file
- * @param [in] loadPol controls time of loading a resource from the filesystem (default: load when Image is created).
- * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
*/
- static NinePatchImagePtr New( const std::string& filename,
- const ImageAttributes& attributes,
- LoadPolicy loadPol = ImageLoadPolicyDefault,
- ReleasePolicy releasePol = ImageReleasePolicyDefault );
+ static NinePatchImagePtr New( const std::string& filename );
/**
* Create a new NinePatchImage
* For better performance and portability use power of two dimensions.
* The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
* @param [in] filename File to load synchronously into buffer
- * @param [in] attributes Image attributes of the file
- * @param [in] loadPol controls time of loading a resource from the filesystem (default: load when Image is created).
- * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
*/
- NinePatchImage( const std::string& filename,
- const ImageAttributes& attributes,
- LoadPolicy loadPol = ImageLoadPolicyDefault,
- ReleasePolicy releasePol = ImageReleasePolicyDefault );
+ NinePatchImage( const std::string& filename );
/**
* Convert Image object to a 9 patch image object if possible.
public:
/**
- * Get the stretch borders
- * @return The border in pixels from the left, top, right, and bottom of the image respectively.
+ * @copydoc Dali::NinePatchImage::GetStretchPixelsX
+ */
+ const StretchRanges& GetStretchPixelsX();
+
+ /**
+ * @copydoc Dali::NinePatchImage::GetStretchPixelsY
*/
- Vector4 GetStretchBorders();
+ const StretchRanges& GetStretchPixelsY();
/**
* Get the child rectangle
*
* @return the cropped bitmap.
*/
- BitmapImagePtr CreateCroppedBitmapImage();
+ BufferImagePtr CreateCroppedBufferImage();
-
-protected: // From Resource
/**
- * @copydoc Dali::Internal::Image::Connect
+ *
+ * @copydoc Dali::NinePatchImage::
*/
- virtual void Connect();
+ static bool IsNinePatchUrl( const std::string& url );
+
+private: // from ResourceImage
/**
- * @copydoc Dali::Internal::Image::Disconnect
+ * @copydoc ResourceImage::GetUrl()
*/
- virtual void Disconnect();
+ virtual const std::string& GetUrl() const;
-private:
/**
* Read the borders of the bitmap and determine the child area
* and stretch borders
*/
void ParseBorders();
+ Uint16Pair ParseRange( unsigned int& index, unsigned int width, const PixelBuffer* & pixel, unsigned int pixelStride, int testByte, int testBits, int testValue );
+
private:
- ResourceClient* mResourceClient;
Integration::BitmapPtr mBitmap;
- Vector4 mStretchBorders;
+ std::string mUrl;
+ StretchRanges mStretchPixelsX; //< The horizontal stretchable pixels in the cropped image space
+ StretchRanges mStretchPixelsY; //< The vertical stretchable pixels in the cropped image space
Rect<int> mChildRectangle;
bool mParsedBorder;
};