Skip to content

Add ABGR format to frombytes and tobytes #2951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

zoldalma999
Copy link
Member

Fixes #1783
The C code for frombytes and tobytes could be cleaned up, but I'll leave that for another PR.

@zoldalma999 zoldalma999 requested a review from a team as a code owner June 23, 2024 11:29
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR 🎉

@ankith26
Copy link
Member

the code do be needing some cleaning

@yunline yunline added the image pygame.image label Jun 24, 2024
Copy link
Member

@damusss damusss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I tested locally and the original image stays perfect, using this code

import pygame
pygame.display.init()
pygame.display.set_mode((10, 10))
img = pygame.image.load("../bg.jpg").convert_alpha()

with open("../out.idk", "wb") as file:
    file.write(pygame.image.tobytes(img, "ABGR"))

with open("../out.idk", "rb") as file:
    b = file.read()
    newimg = pygame.image.frombytes(b, img.size, "ABGR")
    pygame.image.save(newimg, "../fromout.png")

@ankith26 ankith26 added this to the 2.5.1 milestone Jun 28, 2024
@ankith26 ankith26 merged commit 7d9c288 into pygame-community:main Jun 28, 2024
39 checks passed
@zoldalma999 zoldalma999 deleted the frombytes-ABGR branch October 22, 2024 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
image pygame.image
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "ABGR" format to pygame.image.fromstring (3629)
4 participants