[Pixman] Getting started with Pixman

Erico P eri0onpm at gmail.com
Mon Jul 13 23:51:41 UTC 2020


Hey, I finally figured out how to save a bitmap so I can view what I am
operating with pixman!

I made a repository here -> https://github.com/ericoporto/learningPixman

I will try to write down what I learn there on a README eventually. I am
using CMake also, which can be a new source of trouble but I will need it
on the other project so that's why I am using it there.

Thanks!

Em seg., 13 de jul. de 2020 às 08:14, Erico P <eri0onpm at gmail.com> escreveu:

> Thanks for the information!
>
> I wanted to read the pixel for my own save function that I am writing, so
> even if it was slow I would not bother. I want to use pixman to replace
> Allegro4 bitmaps.
>
> From your reply, I think that I need to convert the full bitmap to a
> different format that a .bmp file accepts and then write these converted
> bits to the stream all in one go. I still don't know how to do that. :/
>
>
> I am sorry, I didn't mean a direct reply, I wanted to email the mailist
> actually but I misclicked the reply to all.
>
> On Mon, Jul 13, 2020, 04:29 Pekka Paalanen <ppaalanen at gmail.com> wrote:
>
>> On Sun, 12 Jul 2020 23:24:51 -0300
>> Erico P <eri0onpm at gmail.com> wrote:
>>
>> > Thanks!
>> >
>> > I am trying to get started but I need to read and write bitmaps to see
>> what
>> > I am doing. I made a function to write bitmaps from my own, and made up
>> > some function to read. I can't seem to find anything readymade that
>> > supports all formats available in pixman (r8g8b8a8, ...).
>>
>> Hi,
>>
>> Pixman's format support is so wide and wild (from 1-bit formats
>> where endianness affects also bit order within a byte, to floating
>> point formats nowdays IIRC), that I doubt you will find even a
>> file format that supports everything as is - or if you do, it's
>> really complicated.
>>
>> > I have a small problem that I can't seem to figure out, is there a
>> function
>> > to read or write a single pixel? Maybe it returns an int, or a color
>> (for a
>> > 32bit bmp), or the index of the palette in case it's an indexed bitmap?
>> It
>> > would be really useful for me to be able to read a single pixel, is
>> there a
>> > function for this I am overlooking?
>>
>> I don't think there is, maybe because using it would make things
>> slow so no-one wanted it. Instead, if you need to, you get the
>> pointer to the beginning of the data, compute the appropriate
>> offset from stride, format and position, and access the bits
>> yourself according to the format.
>>
>>
>> https://ppaalanen.blogspot.com/2016/02/a-programmers-view-on-digital-images.html
>> and
>> https://afrantzis.com/pixel-format-guide/
>> might help.
>>
>> You might also mimick that by doing a blit with
>> pixman_image_composite32() from your source image into a 1x1 target
>> image in your preferred inspection format.
>>
>> I'd recommend using just few carefully selected formats for your
>> input/output and use Pixman itself to convert to/from those.
>>
>> If you want to continue the chat, I would like to keep it on the
>> mailing list to benefit everyone and you might get more help, too.
>> It would be nice to CC this reply to the mailing list.
>>
>>
>> Thanks,
>> pq
>>
>> >
>> > Em qua., 8 de jul. de 2020 às 13:23, Pekka Paalanen <
>> ppaalanen at gmail.com>
>> > escreveu:
>> >
>> > > On Wed, 8 Jul 2020 11:43:59 -0300
>> > > Erico P <eri0onpm at gmail.com> wrote:
>> > >
>> > > > Hello,
>> > > >
>> > > > I foundout about pixman recently as a recommended library for
>> efficiently
>> > > > drawing pixels, apparently used when writing a rasterizer and some
>> other
>> > > > use cases in GUIs too.
>> > > >
>> > > > I want to learn how to use it, but unfortunately the webpage
>> states
>> > > "There
>> > > > is currently no documentation besides the source code itself."
>> > > >
>> > > > Is there any documentation available at all, maybe something
>> someone
>> > > wrote
>> > > > some day for someone, anything other than just the source? Maybe a
>> manual
>> > > > from someone who ported it to other language - but I do intend to
>> use it
>> > > in
>> > > > a mixed C/C++ environment.
>> > > >
>> > > > I appreciate any suggestions on getting started with it!
>> > >
>> > > Hi,
>> > >
>> > > I'm not aware of anything particularly about Pixman, unfortunately.
>> > > You'll have to go through code that uses Pixman.
>> > >
>> > > If you want to do rectangular operations,
>> > > pixman_image_composite32() is the main function for practically
>> > > everything. I've used that one, but I never looked into the
>> > > trapezoid or font compositing stuff.
>> > >
>> > >
>> > >
>> https://gitlab.freedesktop.org/wayland/weston/-/blob/master/libweston/pixman-renderer.c
>> > > is one of Weston compositor's renderers that has a relatively
>> > > simple task of just copying and blending window images. Weston also
>> > > uses pixman_region32 for most region tracking and operations.
>> > >
>> > > http://ssp.impulsetrain.com/porterduff.html
>> > > explains the Porter/Duff compositing operations. Some or all of
>> > > those are found in pixman_image_composite32(). It doesn't mention
>> > > the use of a mask though.
>> > >
>> > > Since Cairo can use Pixman underneath, I think some Cairo
>> > > documentation about the image operations are applicable as well:
>> > > https://www.cairographics.org/tutorial/
>> > >
>> > >
>> > > Thanks,
>> > > pq
>> > >
>>
>>
>> --
>> Pekka Paalanen
>> http://www.iki.fi/pq/
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pixman/attachments/20200713/b1a4fd3c/attachment-0001.htm>


More information about the Pixman mailing list