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