libpng 警告:cHRM:无效色度

libpng warning: cHRM: invalid chromaticities

我在文档和网络上没有找到任何有用的方法来解决这个警告。我使用 Python 中的库仅加载少量 png 图像,无非是加载并在屏幕上显示它们。除了这个恼人的警告之外,一切都完美无缺:

libpng 警告:cHRM:色度无效

这是违规代码:

p.s。 CARDICON_1 ... _6 是 png 图片。

def drawIcon(shape, color, boxx, boxy):
    quarter = int(BOXSIZE * 0.25)
    half =    int(BOXSIZE * 0.5)
    half = half
    quarter = quarter
    half = 0
    quarter = 0

    left, top = leftTopCoordsOfBox(boxx, boxy) # get pixel coords from board coords
    # Draw the shapes
    # ALLSHAPES = (CANE, CAPRETTA, GALLINA, MAIALINO, RICCIO, TOPO)
    if shape == CARD1:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        cane = pygame.image.load(CARDICON_1)
        DISPLAYSURF.blit(cane, (left, top))
    elif shape == CARD2:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        capretta = pygame.image.load(CARDICON_2)
        DISPLAYSURF.blit(capretta, (left, top))
    elif shape == CARD3:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        gallina = pygame.image.load(CARDICON_3)
        DISPLAYSURF.blit(gallina, (left, top))
    elif shape == CARD4:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        maialino = pygame.image.load(CARDICON_4)
        DISPLAYSURF.blit(maialino, (left, top))
    elif shape == CARD5:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        riccio = pygame.image.load(CARDICON_5)
        DISPLAYSURF.blit(riccio, (left, top))
    elif shape == CARD6:
        pygame.draw.rect(DISPLAYSURF, color, pygame.Rect(left + quarter, top + quarter, BOXSIZE - half, BOXSIZE - half), 0, EDGERADIUS)
        topo = pygame.image.load(CARDICON_6)
        DISPLAYSURF.blit(topo, (left, top))
#--------------------------------------------------------------------------        

评论汇总:...

您应该能够找到 issues/problems 和 corrupt/incorrect 个 PNG 文件,使用:

pngcheck -v -v UNHAPPY.PNG

您可以使用以下方法修复 corrupt/incorrect 个 PNG 文件:

pngcrush -fix UNHAPPY.PNG

您可以使用以下方法删除 PNG 文件块:

pngcrush -rem CHUNKNAME UNHAPPY.PNG