{
    "content": [
        {
            "type": "text",
            "text": "# Image::Xpm (perldoc)\n\n## NAME\n\nImage::Xpm - Load, create, manipulate and save xpm image files.\n\n## SYNOPSIS\n\nuse Image::Xpm;\nmy $j = Image::Xpm->new(-file, 'Camel.xpm');\nmy $i = Image::Xpm->new(-width => 10, -height => 16);\nmy $h = $i->new; # Copy of $i\n$i->xy(5, 8, 'red');       # Set a colour (& add to palette if necessary)\nprint $i->xy(9, 3);        # Get a colour\n$i->xy(120, 130, '#1256DD');\n$i->xy(120, 130, $i->rgb2colour(66, 0x4D, 31));\n$i->vec(24, '#808080');    # Set a colour using a vector offset\nprint $i->vec(24);         # Get a colour using a vector offset\nprint $i->get(-width);     # Get and set object attributes\n$i->set(-height, 15);\n$i->load('test.xpm');\n$i->save;\n# Changing just the palette\n$i->addcolours(qw(red green blue #123456 #C0C0C0));\n$i->delcolour('blue');\n\n## DESCRIPTION\n\nThis class module provides basic load, manipulate and save functionality for the xpm file\nformat. It inherits from \"Image::Base\" which provides additional manipulation functionality,\ne.g. \"newfromimage()\". See the \"Image::Base\" pod for information on adding your own\nfunctionality to all the Image::Base derived classes.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXAMPLE** (1 subsections)\n- **CHANGES**\n- **AUTHOR**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Image::Xpm",
        "section": "",
        "mode": "perldoc",
        "summary": "Image::Xpm - Load, create, manipulate and save xpm image files.",
        "synopsis": "use Image::Xpm;\nmy $j = Image::Xpm->new(-file, 'Camel.xpm');\nmy $i = Image::Xpm->new(-width => 10, -height => 16);\nmy $h = $i->new; # Copy of $i\n$i->xy(5, 8, 'red');       # Set a colour (& add to palette if necessary)\nprint $i->xy(9, 3);        # Get a colour\n$i->xy(120, 130, '#1256DD');\n$i->xy(120, 130, $i->rgb2colour(66, 0x4D, 31));\n$i->vec(24, '#808080');    # Set a colour using a vector offset\nprint $i->vec(24);         # Get a colour using a vector offset\nprint $i->get(-width);     # Get and set object attributes\n$i->set(-height, 15);\n$i->load('test.xpm');\n$i->save;\n# Changing just the palette\n$i->addcolours(qw(red green blue #123456 #C0C0C0));\n$i->delcolour('blue');",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "my $i = Image::Xpm(-file => 'test1.xpm'); # test1.xpm has cpp == 1",
            "my $j = $i->newfromimage('Image::xpm', -cpp => 2);",
            "$j->save('test2.xpm');",
            "# Could have written 2nd line above as:",
            "my $j = $i->newfromimage(ref $i, -cpp => 2);"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 153,
                "subsections": []
            },
            {
                "name": "EXAMPLE",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Changing the -cpp of an image:",
                        "lines": 7
                    }
                ]
            },
            {
                "name": "CHANGES",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Image::Xpm - Load, create, manipulate and save xpm image files.\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Image::Xpm;\n\nmy $j = Image::Xpm->new(-file, 'Camel.xpm');\n\nmy $i = Image::Xpm->new(-width => 10, -height => 16);\n\nmy $h = $i->new; # Copy of $i\n\n$i->xy(5, 8, 'red');       # Set a colour (& add to palette if necessary)\nprint $i->xy(9, 3);        # Get a colour\n\n$i->xy(120, 130, '#1256DD');\n$i->xy(120, 130, $i->rgb2colour(66, 0x4D, 31));\n\n$i->vec(24, '#808080');    # Set a colour using a vector offset\nprint $i->vec(24);         # Get a colour using a vector offset\n\nprint $i->get(-width);     # Get and set object attributes\n$i->set(-height, 15);\n\n$i->load('test.xpm');\n$i->save;\n\n# Changing just the palette\n$i->addcolours(qw(red green blue #123456 #C0C0C0));\n$i->delcolour('blue');\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This class module provides basic load, manipulate and save functionality for the xpm file\nformat. It inherits from \"Image::Base\" which provides additional manipulation functionality,\ne.g. \"newfromimage()\". See the \"Image::Base\" pod for information on adding your own\nfunctionality to all the Image::Base derived classes.\n\nnew()\nmy $i = Image::Xpm->new(-file => 'test.xpm');\nmy $j = Image::Xpm->new(-width => 12, -height => 18);\nmy $k = $i->new;\n\nWe can create a new xpm image by reading in a file, or by creating an image from scratch (all\nthe pixels are white by default), or by copying an image object that we created earlier.\n\nIf we set \"-file\" then all the other arguments are ignored (since they're taken from the file).\nIf we don't specify a file, \"-width\" and \"-height\" are mandatory and \"-cpp\" will default to 1\nunless specified otherwise.\n\n\"-file\"\nThe name of the file to read when creating the image. May contain a full path. This is also\nthe default name used for \"load\"ing and \"save\"ing, though it can be overridden when you load\nor save.\n\n\"-width\"\nThe width of the image; taken from the file or set when the object is created; read-only.\n\n\"-height\"\nThe height of the image; taken from the file or set when the object is created; read-only.\n\n\"-cpp\"\nCharacters per pixel. Commonly 1 or 2, default is 1 for images created by the module;\nread-only.\n\nSee the example for how to change an image's cpp.\n\n\"-hotx\"\nThe x-coord of the image's hotspot; taken from the file or set when the object is created.\nSet to -1 if there is no hotspot.\n\n\"-hoty\"\nThe y-coord of the image's hotspot; taken from the file or set when the object is created.\nSet to -1 if there is no hotspot.\n\n\"-ncolours\"\nThe number of unique colours in the palette. The image may not be using all of them;\nread-only.\n\n\"-cindex\"\nAn hash whose keys are colour names, e.g. '#123456' or 'blue' and whose values are the\npalette names, e.g. ' ', '#', etc; read-only. If you want to add more colours to the image\nitself simply write pixels with the new colours using \"xy\"; if you want to add more colours\nto the palette without necessarily using them in the image use \"addcolours\".\n\n\"-palette\"\nA hash whose keys are the palette names, e.g. ' ', '#', etc. and whose values are hashes of\ncolour type x colour name pairs, e.g. \"c => red\", etc; read-only. If you want to add more\ncolours to the image itself simply write pixels with the new colours using \"xy\"; if you want\nto add more colours to the palette without necessarily using them in the image use\n\"addcolours\".\n\n\"-pixels\"\nA string of palette names which constitutes the data for the image itself; read-only.\n\n\"-extname\"\nThe name of the extension text if any; commonly XPMEXT; read-only.\n\n\"-extlines\"\nThe lines of text of any extensions; read-only.\n\n\"-comments\"\nAn array (possibly empty) of comment lines that were in a file that was read in; they will\nbe written out although we make no guarantee regarding their placement; read-only.\n\nget()\nmy $width = $i->get(-width);\nmy ($hotx, $hoty) = $i->get(-hotx, -hoty);\n\nGet any of the object's attributes. Multiple attributes may be requested in a single call.\n\nSee \"xy\" and \"vec\" to get/set colours of the image itself.\n\nset()\n$i->set(-hotx => 120, -hoty => 32);\n\nSet any of the object's attributes. Multiple attributes may be set in a single call; some\nattributes are read-only.\n\nSee \"xy\" and \"vec\" to get/set colours of the image itself.\n\nxy()\n$i->xy(4, 11, '#123454');    # Set the colour at point 4,11\nmy $v = $i->xy(9, 17);       # Get the colour at point 9,17\n\nGet/set colours using x, y coordinates; coordinates start at 0. If the colour does not exist in\nthe palette it will be added automatically.\n\nWhen called to set the colour the value returned is characters used for that colour in the\npalette; when called to get the colour the value returned is the colour name, e.g. 'blue' or\n'#f0f0f0', etc, e.g.\n\n$colour = xy($x, $y);            # e.g. #123456\n$cc     = xy($x, $y, $colour);   # e.g. !\n\nWe don't normally pick up the return value when setting the colour.\n\nvec()\n$i->vec(43, 0);      # Unset the bit at offset 43\nmy $v = $i->vec(87); # Get the bit at offset 87\n\nGet/set bits using vector offsets; offsets start at 0. The offset of a pixel is ((y * width *\ncpp) + (x * cpp)).\n\nThe sort of return value depends on whether we are reading (getting) or writing (setting) the\ncolour - see \"xy\" for an explanation.\n\nrgb2colour() and rgb2color()\n$i->rgb2colour(0xff, 0x40, 0x80);    # Returns #ff4080\nImage::Xpm->rgb2colour(10, 20, 30);  # Returns #0a141e\n\nConvenience class or object methods which accept three integers and return a colour name string.\n\nload()\n$i->load;\n$i->load('test.xpm');\n\nLoad the image whose name is given, or if none is given load the image whose name is in the\n\"-file\" attribute.\n\nsave()\n$i->save;\n$i->save('test.xpm');\n\nSave the image using the name given, or if none is given save the image using the name in the\n\"-file\" attribute. The image is saved in xpm format.\n\naddcolours() and addcolors()\n$i->addcolours(qw(#C0C0DD red blue #123456));\n\nThese are for adding colours to the palette; you don't need to use them to set a pixel's colour\n- use \"xy\" for that.\n\nAdd one or more colour names either as hex strings or as literal colour names. These are always\nadded as type 'c' colours; duplicates are ignored.\n\nNB If you just want to set some pixels in colours that may not be in the palette, simply do so\nusing \"xy\" since new colours are added automatically.\n\ndelcolour() and delcolor()\n$i->delcolour('green');\n\nDelete a colour from the palette; returns undef if the colour isn't in the palette, false (0) if\nthe colour is in the palette but also in the image, or true (1) if the colour has been deleted\n(i.e. it was in the palette but not in use in the image).\n",
                "subsections": []
            },
            "EXAMPLE": {
                "content": "",
                "subsections": [
                    {
                        "name": "Changing the -cpp of an image:",
                        "content": "my $i = Image::Xpm(-file => 'test1.xpm'); # test1.xpm has cpp == 1\nmy $j = $i->newfromimage('Image::xpm', -cpp => 2);\n$j->save('test2.xpm');\n\n# Could have written 2nd line above as:\nmy $j = $i->newfromimage(ref $i, -cpp => 2);\n"
                    }
                ]
            },
            "CHANGES": {
                "content": "2000/11/09\n\nAdded Jerrad Pierce's patch to allow load() to accept filehandles or strings; will document in\nnext release.\n\n2000/10/19\n\nFixed bugs in xy() and vec() reported by Pat Gunn.\n\n2000/05/25\n\nFixed a bug in the test file; fixed a bug in save() which affected xpm extensions.\n\n2000/05/04\n\nFixed bugs in xy(), vec(), save() and load(). Improved the test program.\n\n2000/05/03\n\nCreated.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Mark Summerfield. I can be contacted as <summer@perlpress.com> - please include the word 'xpm'\nin the subject line.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) Mark Summerfield 2000. All Rights Reserved.\n\nThis module may be used/distributed/modified under the GPL.\n",
                "subsections": []
            }
        }
    }
}