ImageSubDivide

Gamma/Photon: Using Gamma™ with the Photon microGUIŽ, Version 4.0
Prev |  | Next

# `ImageSubDivide`

`ImageSubDivide` -- divides an image into columns and rows.

## Syntax

    ImageSubDivide (image, cols, rows)

## Arguments

`image`

  An 8-bit image, instance of the PhImage class, such as returned by a call to PxLoadImage.

`cols`

  The number of columns to divide the image into.

`rows`

  The number of rows to divide the image into.

## Returns

A list of images on success, otherwise nil.

## Description

This function divides the passed `image` into the number of rows and columns specified, and puts the subimages into a list, by rows. That is, the first elements of the list are the subimages of row 1, then the subimages of row 2, etc.

To use this function, you must load the ImageProc.lsp library with a call to `require_lisp("ImageProc.lsp")`.

## Example

This example, `ex_ImageSubDivide.g`, is included in the `gamma_ph_`#`_examples_1_QNX4.tgz` file available on the Cogent Web Site.

    #!/usr/cogent/bin/phgamma

    /*
    This example puts up a window with a label image.  (Size: 96 by 96
    pixels). Next to this image is the same image sub_divided into four
    parts on four separate labels.
    */

    PtInit(nil);
    require_lisp("PhotonWidgets.lsp");
    require_lisp("ImageProc.lsp");

    win = new(PtWindow);
    win.SetDim(300,160);

    img = PxLoadImage("smiley.bmp");
    lab = ImageToLabel(img);
    lab.SetPos(25,25);

    sub_img = (ImageSubDivide(img,2,2));

    lab1 = ImageToLabel(car(sub_img));
    lab1.SetPos(150,25);

    lab2 = ImageToLabel(cadr(sub_img));
    lab2.SetPos(210,25);

    lab3 = ImageToLabel(caddr(sub_img));
    lab3.SetPos(150,85);

    lab4 =ImageToLabel(caddr(cdr(sub_img)));
    lab4.SetPos(210,85);

    PtRealizeWidget(win);
    PtMainLoop();

## See Also

PxLoadImage

Prev | Home | Next
Graphics Functions | Up | `ImageThumbNail`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.