"CountScubula" <me@scantek.hotmail.com> wrote in message news:<bEdUb.20202$CX7.1043@newssvr27.news.prodigy. com>...[color=blue]
> sorry, I didnt really look at the code, how is it breaking, error, not
> working?[/color]
I'll show you, just go down and view...
Phil
[color=blue]
>
> --
> Mike Bradley
>
http://www.gzentools.com -- free online php tools
> "Phil Powell" <soazine@erols.com> wrote in message
> news:1cdca2a7.0402040711.63478c64@posting.google.c om...[color=green]
> > I'm sorry but that too breaks. Perhaps a code review is in order, I
> > realize that imageColorsTotal($this->image) produces 0, which I am
> > afraid I don't understand:
> >
> > class ImageGrayscaleGenerator {
> >
> >[/color]
> /*--------------------------------------------------------------------------
> ----------------------------------------------------------------------------
> ---[color=green]
> > This class exists due to the rather poor performance of the
> > imagecopymergegray() command
> > Borrowing code snippet from
> >
http://us3.php.net/manual/en/functio...ymergegray.php first
> > line comment
> > Will perform actual grayscaling of image one pixel at a time.
> > --------------------------------------------------------------------------[/color]
> ----------------------------------------------------------------------------
> -----*/[color=green]
> >
> > var $image, $image_width, $image_height;
> >
> > // REMEMBER TO USE REFERENCE POINTER ONTO $image OBJECT TO ENSURE
> > "static" CHANGE TO OBJECT AND NOT TO INSTANCE
> >
> > function ImageGrayscaleGenerator(&$image) { // CONSTRUCTOR
> > $this->image =& $image;
> > }
> >
> > function makeGray() { // VOID METHOD
> > print_r($this->image); print_r("<P>");
> > print_r(@imageColorsTotal($this->image) . "<P>");[/color][/color]
** STOP HERE! What happens is that imageColorsTotal($this->image) =
0! Though the image is in color and I do a reference pointer to the
$image resource paramters in the method call, and it actually DOES
change the image according to the value of
imageColorsTotal($this->image), it turns the entire image into one
jet-black image, no tone, no hue, nothing, a big black box.
Phil
[color=blue][color=green]
> > for ($i = 0; $i < @imagecolorstotal($this->image); $i++) {
> > $colorArray = @imageColorsForIndex($this->image, $i);
> > print_r($colorArray); print_r("<P>");
> > $avg = floor(($colorArray['red'] + $colorArray['green'] +
> > $colorArray['blue']) / 3);
> > @imageColorSet($this->image, $i, $avg, $avg, $avg);
> > }
> > }
> > }
> >
> >
> > Thanx
> > Phil
> >
> > "CountScubula" <me@scantek.hotmail.com> wrote in message[/color]
> news:<_rSTb.19724$up5.18401@newssvr27.news.prodigy .com>...[color=green][color=darkred]
> > > Try running an average of the three colors:
> > > $avg = floor( ( $color['red']) + $color['green']) + $color['blue']) ) /[/color][/color]
> 3 )[color=green][color=darkred]
> > > $R= $avg; $B = $avg; $G = $avg;
> > > imageColorSet($image_id, $a, $R, $G, $B);
> > >
> > >
> > > --
> > > Mike Bradley
> > >
http://www.gzentools.com -- free online php tools
> > > "Phil Powell" <soazine@erols.com> wrote in message
> > > news:1cdca2a7.0402030910.a9109fc@posting.google.co m...
> > > > I borrowed this code from a source:
> > > >
> > > >
> > > >
> > > > for($a=0;$a<imagecolorstotal ($image_id);$a++)
> > > > {
> > > > $color = imageColorsForIndex($image_id,$i);
> > > > $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
> > > > ($color['blue']);
> > > > $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
> > > > ($color['blue']);
> > > > $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
> > > > ($color['blue']);
> > > > imageColorSet($image_id, $a, $R, $G, $B);
> > > > }
> > > >
> > > > using an image (in this case I'm using a JPEG) that is a true color
> > > > image I was unable to successfully use imagecopymergegray since that
> > > > washed out my hues/saturation altogether making the image illegible
> > > > (imagecopymergegray + imagecreate); otherwise, the colors overrode
> > > > imagecopymergegray (imagecopymergegray + imagecreatetruecolor).
> > > >
> > > > Using the code I borrowed I was able to change the image.. except that
> > > > it turned jet black instead!
> > > >
> > > > Has anyone ever successfully grayscaled an image using GD library? If
> > > > so, how did you do it?
> > > >
> > > > Thanx
> > > > Phil[/color][/color][/color]