+++ /dev/null
-#include <algorithm>
-#include "gl.h"
-#include "pixelformat.h"
-#include "pixelstore.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-PixelStore::PixelStore():
- row_length(0),
- image_height(0),
- skip_pixels(0),
- skip_rows(0),
- skip_images(0),
- alignment(4)
-{ }
-
-PixelStore PixelStore::from_image(const Graphics::Image &img)
-{
- PixelStore pstore;
- unsigned stride = img.get_stride();
- unsigned ncomp = get_component_count(pixelformat_from_graphics(img.get_format()));
- pstore.set_canvas_size(img.get_stride()/ncomp, 0);
- pstore.set_alignment(min(stride&~(stride-1), 8U));
- return pstore;
-}
-
-void PixelStore::set_canvas_size(unsigned w, unsigned h)
-{
- row_length = w;
- image_height = h;
-}
-
-void PixelStore::set_origin(unsigned x, unsigned y, unsigned z)
-{
- skip_pixels = x;
- skip_rows = y;
- skip_images = z;
-}
-
-void PixelStore::set_alignment(unsigned a)
-{
- alignment = a;
-}
-
-void PixelStore::bind() const
-{
- if(set_current(this))
- {
- glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
- glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
- glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images);
- glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
- }
-}
-
-} // namespace GL
-} // namespace Msp