Recent

Author Topic: Smooth gradient  (Read 6995 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Smooth gradient
« Reply #15 on: December 01, 2015, 09:02:05 pm »
There was a mistake in Lazpaint example and I set alpha 200 for it,I chnaged it and the Lazpaint Result is just like gamma True test.

Also I test with my color in the first example (179, 130, 210) and now Photoshop example has more union effect and size is more like BGRA tests but these are still questions for me:
-The reason of union rings and Photoshop difference and reason of increasing when I change color and solution.
-File size difference.
https://www.dropbox.com/s/cud0zv3l4zbf977/testgradient2.zip?dl=1

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Smooth gradient
« Reply #16 on: December 01, 2015, 09:19:12 pm »
I looked at the Photoshop file, it is more or less the same as without gamma correction with BGRABitmap, except that there is some dithering. I thought about dithering and that could be an extra option to gradients. But that would not solve the problem when combining many times the same layer.

The only proper way, while still using layers, would be to use more precision for bitmaps, like 16 bits per channel, or floating point values, which is a bit out of the scope of BGRABitmap.

For the PNG, this derives from the PNG writer of Freepascal, which is not very optimised.

I guess that for the effect you are trying to achieve, it would make more sense to have an equation to generate the gradient in one step for each pixel. You could then as much precision as you want, and only reduce the quality in the end, when setting the RGB value for the pixel.
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Smooth gradient
« Reply #17 on: December 01, 2015, 09:22:17 pm »
Quote
I guess that for the effect you are trying to achieve, it would make more sense to have an equation to generate the gradient in one step for each pixel. You could then as much precision as you want, and only reduce the quality in the end, when setting the RGB value for the pixel.
How can I make something like this? Can you explain more?
I just know gradient is a function in BGRABitmap  :D

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Smooth gradient
« Reply #18 on: December 01, 2015, 09:32:06 pm »
You can go through the pixels, using a PBGRAPixel and x,y variables.

Then for each pixel, you can compute a value with floating point values. The type TColorF for example contains four floating point values. The color for a pixel is something like:
  CenterColor + (BorderColor-CenterColor)*DistanceToCenter/Radius

You can add such of computation for multiple centers and divide by the number of values to get the average.

The distance to the center is sqrt(sqr(x- xCenter)+sqr(y - yCenter))
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Smooth gradient
« Reply #19 on: December 01, 2015, 09:34:27 pm »
Thanks.
I am trying to understand  :D

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Smooth gradient
« Reply #20 on: December 01, 2015, 09:45:04 pm »
Maybe you can have a look at the gradient scanner in BGRABitmap, that can give you some example of how to compute the gradient value.
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Smooth gradient
« Reply #21 on: December 01, 2015, 09:49:52 pm »
Yes Im looking at it right now but it seems more complicated and I hope I get it.
As I said before Im not good at understanding pixel,I just like to put this function together and make something new
Thanks for helps.

 

TinyPortal © 2005-2018