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

Re: Image Loading in Crystal Space (was Re: Tools)



Jan Ekholm wrote:

>
> Speaking of formats, does anybody have a link or other reference to some
> info on how libpng should be used to load PNG:s? I've spent some time
> reading part of the docs, but there is too much that potentially must be
> done to load an image in order for me to understand it. I'm basically
> looking for something that would give me a function such as:
>
>         bool loadPNG (const string & Filename) { ... }
>
> and then a pointer to raw RGB or RGBA data. The examples in the libpng
> package are *huge*, and do a lot of things I don't have a clue as to what
> they do... Maybe the code in Crystal Space is nicely packaged into a
> single function/method or class? Does anyone know?
>
>

To load an image in CS (regardless of format) you do:

    // Assume 'buf' points to the file data (can be read in with fopen/fread
    // or just be allocated in memory somewhere) and 'size' is the size
    // of that buffer.
    csImageFile* image_file = csImageLoader::load (buf, size);

This function will detect the format and then load the image in RGB format.
You can then call things like GetImageData(), GetWidth(), GetHeight(), ...
and so on.

Greetings,


--
==============================================================================
Jorrit.Tyberghein@uz.kuleuven.ac.be, University Hospitals KU Leuven BELGIUM

"Worlds only harmonica-playing dog. Tuppence."
        -- Gaspode the wonder dog
           (Terry Pratchett, Moving Pictures)
==============================================================================