Rafael Latowicz

Results 24 comments of Rafael Latowicz

Cairo's ARGB32 format is BGRA in pygame format. But pygame doesn't offer BGRA :) Using BGR as the example, https://github.com/pygame/pygame/blob/main/src_c/image.c#L1141 BGRA would look something like, ``` else if (!strcmp(format, "BGRA"))...

I compiled pygame with the changes to **image.c**, as I outlined above. Success! However, not fully tested!! pygame/pycairo code to use will be, ``` # Create Cairo surface cairo_surface =...

It should be noted that the video is showing some compression artifacts. But indeed it is all nicely antialised, ![2022-07-23 03_03_52-'BGRA' format added to image c - 2022-07-23](https://user-images.githubusercontent.com/12681122/180489136-3e351329-3b4d-49bf-bf95-a7457f31a9de.png)

Using the example for `RGBA_PREMULT`, [image.c#L756](https://github.com/pygame/pygame/blob/main/src_c/image.c#L756) ``` else if (!strcmp(format, "RGBA_PREMULT")) { ... } ``` and switching R & B values. Seems straightforward. But that is code for, [pygame.image.tostring()](http://www.pygame.org/docs/ref/image.html#pygame.image.tostring) To...

Looking at this, [pil-prevent-premultiplied-alpha-channel](https://stackoverflow.com/questions/39069681/pil-prevent-premultiplied-alpha-channel) and [OpenImageIO - premult, unpremult, ...](https://openimageio.readthedocs.io/en/master/imagebufalgo.html#group__premult_1gad93213ec645151c2cf649e4bf22a9091) It might be useful to some to offer an `unpremult` option, `converter(data, source_RGBA_format, destination_RGBA_format, premult_type = no_premult)` `premult_type` is either...

@MyreMylar I agree. In regards to the converter, it should probably offer both an inplace conversion (faster) as well as the option to return a new buffer. Or separate functions...

Using @Starbuck5 's example above, this is a minimal workbench for testing a premult, ``` import pygame import cairo def premult(din): dout = bytearray(len(din)) pixel_count = len(din) >> 2 for...

The inplace version, ``` import pygame import cairo def premult_inplace(din): pixel_count = len(din) >> 2 for i in range(pixel_count): i4 = i > 8 din[i4 + 1] = din[i4 +...

This was added to SDL in Nov 2021, [SDL_PremultiplyAlpha](https://wiki.libsdl.org/SDL_PremultiplyAlpha) and [sdl-added-sdl-premultiplyalpha-to-premultiply-alpha-on-a-block-of-sdl-pixelformat-argb8888-pixels](https://discourse.libsdl.org/t/sdl-added-sdl-premultiplyalpha-to-premultiply-alpha-on-a-block-of-sdl-pixelformat-argb8888-pixels/33608) Note that ARGB32 is an alias for ARGB8888, [SDL_PixelFormatEnum](https://wiki.libsdl.org/SDL_PixelFormatEnum) But it hasn't been wrapped by pygame code. Code is...

I got this working, ![2022-07-24 12_45_32-D__Coding_Work_cairo_graphics_pygame_pycairo_looking_at bytes_004 py - SciTE](https://user-images.githubusercontent.com/12681122/180629985-ec21c763-dd6a-400c-a06e-a17cb28860a2.png)