[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pngpp-devel] Raw Data

From: Alexander Shulgin
Subject: Re: [pngpp-devel] Raw Data
Date: Wed, 30 Jul 2008 12:26:20 +0300

On Tue, Jul 29, 2008 at 10:51 PM, Kambiz V <address@hidden> wrote:
> I load the image with
> png::image<png::rgba_pixel> image(path.c_str());
> but how can I now access the raw data? I need a pointer I can pass to
> gluBuild2DMipmaps.

Unfortunately, this might not be possible when using plain
png::image<>, since it stores pixels in a vector of vectors.  However,
you may copy image pixels row-by-row to continuous buffer like this
(not tested):

std::vector< png::rgba_pixel > raw(image.get_width() * image.get_height());
for (size_t i = 0; i < image.get_height(); ++i)
    std::copy(image.get_row(i).begin(), image.get_row(i).end(),
raw.begin() + i*image_get_width());

Or you may implement a custom pixel buffer which will store pixels
continuously and a pixel consumer to copy pixels received from libpng
into that buffer.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]