3 #include "pixelformat.h"
4 #include "pixelstore.h"
11 PixelStore::PixelStore():
20 PixelStore PixelStore::from_image(const Graphics::Image &img)
23 unsigned stride = img.get_stride();
24 unsigned ncomp = get_component_count(pixelformat_from_graphics(img.get_format()));
25 pstore.set_canvas_size(img.get_stride()/ncomp, 0);
26 pstore.set_alignment(min(stride&~(stride-1), 8U));
30 void PixelStore::update_parameter(int mask) const
37 glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
38 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height);
42 glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
43 glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
44 glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images);
47 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
50 void PixelStore::set_canvas_size(unsigned w, unsigned h)
54 update_parameter(SIZE);
57 void PixelStore::set_origin(unsigned x, unsigned y, unsigned z)
62 update_parameter(ORIGIN);
65 void PixelStore::set_alignment(unsigned a)
68 update_parameter(ALIGNMENT);
71 void PixelStore::bind() const