From 4bd6922f06fc481a0e4c1e778f7ddd6f70b2fd52 Mon Sep 17 00:00:00 2001 From: Mark Friedman Date: Wed, 3 Jul 1991 16:15:46 +0000 Subject: [PATCH] Added X-BYTES-INTO-IMAGE which takes a vector-8b and an image and sticks the bytes from the vector into the image. --- v7/src/microcode/x11graph.c | 40 ++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/v7/src/microcode/x11graph.c b/v7/src/microcode/x11graph.c index 044337ac0..39c96f1be 100644 --- a/v7/src/microcode/x11graph.c +++ b/v7/src/microcode/x11graph.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.11 1991/07/02 18:18:43 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.12 1991/07/03 16:15:46 markf Exp $ Copyright (c) 1989-91 Massachusetts Institute of Technology @@ -519,13 +519,13 @@ DEFINE_PRIMITIVE ("X-GRAPHICS-SET-DASHES", Prim_x_graphics_set_dashes, 3, 3, 0) PRIMITIVE_RETURN (UNSPECIFIC); } -DEFINE_PRIMITIVE ("X-CREATE-IMAGE", Prim_x_create_image, 3, 3, 0) -{ - /* Arguments: Window, width, height - Returns: A Scheme image +DEFINE_PRIMITIVE ("X-CREATE-IMAGE", Prim_x_create_image, 3, 3, + " Arguments: Window, width, height + Returns: A Scheme image - The window is used to find the Display, Visual, and Depth - information needed to crate an XImage structure. */ + The window is used to find the Display, Visual, and Depth + information needed to crate an XImage structure.") +{ extern allocate_x_image (); PRIMITIVE_HEADER (3); { @@ -563,6 +563,32 @@ DEFINE_PRIMITIVE ("X-CREATE-IMAGE", Prim_x_create_image, 3, 3, 0) } } +DEFINE_PRIMITIVE ("X-BYTES-INTO-IMAGE", Prim_x_bytes_into_image, 2, 2, + "Stick the bytes from the vector-8b (first arg) into the x_image +(second arg).") +{ + PRIMITIVE_HEADER (2); + { + SCHEME_OBJECT vector = ARG_REF (1); + XImage * image = XI_IMAGE (x_image_arg (2)); + char * image_scan; + unsigned long width = (image -> width); + unsigned long height = (image -> height); + int x, y; + + if (! (STRING_P (vector))) + error_wrong_type_arg (1); + if (STRING_LENGTH(vector) != (width * height)) + error_bad_range_arg (1); + + image_scan = ((char *) STRING_LOC (vector, 0)); + for (y = 0; y < height; y++) + for (x = 0; x < width; x++) + XPutPixel (image, x, y, ((unsigned long) *image_scan++)); + PRIMITIVE_RETURN (UNSPECIFIC); + } +} + DEFINE_PRIMITIVE("X-GET-PIXEL-FROM-IMAGE", Prim_x_get_image_pixel, 3, 3, 0) { PRIMITIVE_HEADER (3); -- 2.25.1