Skip to content

Instantly share code, notes, and snippets.

@dobrych
Last active December 19, 2015 21:28
Show Gist options
  • Select an option

  • Save dobrych/6019979 to your computer and use it in GitHub Desktop.

Select an option

Save dobrych/6019979 to your computer and use it in GitHub Desktop.

Revisions

  1. dobrych revised this gist Jul 23, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion read_png_row_to_json.py
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    data = list(res[2])

    # second row, first one could be distorted
    data[1]
    # data[1]

    json_palette = ["rgb%s" % str(palette[v]) for v in data[1]]

  2. dobrych created this gist Jul 17, 2013.
    17 changes: 17 additions & 0 deletions read_png_row_to_json.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import png

    f = open('palette.png', 'r')

    p = png.Reader(f)

    res = p.read()

    palette = res[3]['palette']
    data = list(res[2])

    # second row, first one could be distorted
    data[1]

    json_palette = ["rgb%s" % str(palette[v]) for v in data[1]]

    print json_palette