function callback($img, $arg) { #fwrite(STDERR, "callback in object: arg=" . print_r($arg, True) . "\nimg=" . print_r($img, True) . "\n"); # fwrite(STDERR, print_r($this, True)); #fwrite(STDERR, "Plot area: ({$this->plot_area[0]}, {$this->plot_area[1]}) :"); #fwrite(STDERR, " ({$this->plot_area[2]}, {$this->plot_area[2]})\n"); # Draw an X across the plot area. $red = ImageColorResolve($img, 255, 0, 0); ImageLine($img, $this->plot_area[0], $this->plot_area[1], $this->plot_area[2], $this->plot_area[3], $red); ImageLine($img, $this->plot_area[0], $this->plot_area[3], $this->plot_area[2], $this->plot_area[1], $red); }
function SetIndexDarkColor($which_color) { list($r, $g, $b) = $this->SetRGBColor($which_color); $r = max(0, $r - 0x30); $g = max(0, $g - 0x30); $b = max(0, $b - 0x30); return ImageColorResolve($this->img, $r, $g, $b); }
function PrintError($error_message) { // Be sure not to loop recursively, e.g. PrintError - PrintImage - PrintError. if (isset($this->in_error)) { return FALSE; } $this->in_error = TRUE; // Output an image containing the error message: if (!empty($this->img)) { $ypos = $this->image_height / 2; $xpos = $this->image_width / 2; $bgcolor = ImageColorResolve($this->img, 255, 255, 255); $fgcolor = ImageColorResolve($this->img, 0, 0, 0); ImageFilledRectangle($this->img, 0, 0, $this->image_width, $this->image_height, $bgcolor); // Switch to built-in fonts, in case of error with TrueType fonts: $this->SetUseTTF(FALSE); $this->DrawText($this->fonts['generic'], 0, $xpos, $ypos, $fgcolor, wordwrap($error_message), 'center', 'center'); $this->PrintImage(); } elseif (!$this->is_inline) { Header('HTTP/1.0 500 Internal Server Error'); } trigger_error($error_message, E_USER_ERROR); unset($this->in_error); return FALSE; # In case error handler returns, rather than doing exit(). }
function SetIndexDarkColor($which_color) { list($r, $g, $b) = $this->SetRGBColor($which_color); $r -= 0x30; $r = $r < 0 ? 0 : $r; $g -= 0x30; $g = $g < 0 ? 0 : $g; $b -= 0x30; $b = $b < 0 ? 0 : $b; $index = ImageColorExact($this->img, $r, $g, $b); if ($index == -1) { return ImageColorResolve($this->img, $r, $g, $b); } else { return $index; } }
function SetIndexColor($which_color) { //Color is passed in as anything list($r, $g, $b) = $this->SetRgbColor($which_color); //Translate to RGB $index = ImageColorExact($this->img, $r, $g, $b); if ($index == -1) { //return ImageColorAllocate($this->img, $r, $g, $b); //return ImageColorClosest($this->img, $r, $g, $b); return ImageColorResolve($this->img, $r, $g, $b); //requires PHP 3.0.2 and later } else { return $index; } }