PHP-GTK
Wednesday, November 26, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previousGdkPixbuf::get_option
GdkPixbuf::get_pixelsnext

Last updated: Sun, 12 May 2013
view this page in English

GdkPixbuf::get_pixel

Returns the color of a single pixel. The number returned is a pixel specification. See the example on how to split it into usable values.

Example 9. Get the color of a certain pixel

<?php
//Create a new pixbuf of size 320x240
$pixbuf = new GdkPixbuf(Gdk::COLORSPACE_RGB, true, 8, 320, 240);
 
//green, half-transparent
//overwrites the previously set color
$pixbuf->fill(128, 255, 0, 128);
echo "setting: (128,255,0,128)\n";
 
//now get the pixel at a certain position
$pixel = $pixbuf->get_pixel(10, 20);
echo 'pixel: ' . $pixel . "\n";
 
$r = ($pixel & 0xff000000) >> 24;
$g = ($pixel & 0x00ff0000) >> 16;
$b = ($pixel & 0x0000ff00) >> 8;
$a = ($pixel & 0x000000ff);
echo "rgba: ($r,$g,$b,$a)\n";
?>

See also: put_pixel()


User Contributed Notes
gdk.gdkpixbuf.method.get_pixel.php
add a note about notes
There are no user contributed notes for this page.


previousGdkPixbuf::get_option
GdkPixbuf::get_pixelsnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:50:55 2013 CEST