dmuratshin 9 years ago
parent
commit
085d81db37
4 changed files with 27 additions and 0 deletions
  1. 10 0
      oxygine/src/Image.cpp
  2. 3 0
      oxygine/src/Image.h
  3. 12 0
      oxygine/src/core/ImageData.cpp
  4. 2 0
      oxygine/src/core/ImageData.h

+ 10 - 0
oxygine/src/Image.cpp

@@ -805,6 +805,16 @@ namespace oxygine
         return lock(lock_read | lock_write, &rect);
     }
 
+    ImageData Image::lock(int x, int y, int w, int h)
+    {
+        return lock(Rect(x, y, w, h));
+    }
+
+    ImageData Image::lock(int x, int y)
+    {
+        return lock(Rect(x, y, _image.w - x, _image.h - y));
+    }
+
     void Image::unlock()
     {
 

+ 3 - 0
oxygine/src/Image.h

@@ -46,6 +46,9 @@ namespace oxygine
         ImageData   lock(lock_flags f = 0, const Rect* pRect = 0);
         ImageData   lock(const Rect* pRect);
         ImageData   lock(const Rect& pRect);
+        ImageData   lock(int x, int y, int w, int h);
+        ImageData   lock(int x, int y);
+
         void        unlock();
         void        toPOT(Image& dest);
 

+ 12 - 0
oxygine/src/core/ImageData.cpp

@@ -142,6 +142,8 @@ namespace oxygine
 
     ImageData ImageData::getRect(const Rect& r) const
     {
+        OX_ASSERT(r.getX() >= 0 && r.getX() <= w);
+        OX_ASSERT(r.getY() >= 0 && r.getY() <= h);
         OX_ASSERT(r.getX() + r.getWidth() <= w);
         OX_ASSERT(r.getY() + r.getHeight() <= h);
 
@@ -151,6 +153,16 @@ namespace oxygine
         return buffer;
     }
 
+    ImageData ImageData::getRect(int x, int y, int w, int h) const
+    {
+        return getRect(Rect(x, y, w, h));
+    }
+
+    ImageData ImageData::getRect(int x, int y) const
+    {
+        return getRect(x, y, w - x, h - y);
+    }
+
     unsigned char* ImageData::getPixelPtr(int x, int y) const
     {
         return (unsigned char*)data + x * bytespp + y * pitch;

+ 2 - 0
oxygine/src/core/ImageData.h

@@ -60,6 +60,8 @@ namespace oxygine
         ~ImageData();
 
         ImageData getRect(const Rect& r) const;
+        ImageData getRect(int x, int y, int w, int h) const;
+        ImageData getRect(int x, int y) const;
         unsigned char* getPixelPtr(int x, int y) const;
 
     public: