Jump to content

Brightness control


Recommended Posts

I know it's a lot faster to apply a color matrix, but the results are not as pleasing to the client (going from completely black to comletely white).

Would you be willing to include a proportional slider/setting that enables this feature?

I just stumbled across your program yesterday when my old, trusted PaintShopPro refused to load anything above 24 bit RGB, and the software I am working on

created images that added an alpha byte.

OK, is there anything wrong with this:

               int srcBytes = srcData.Stride / srcData.Width;
               int dstBytes = dstData.Stride / dstData.Width;

               byte* srcPtr = (byte*)(srcData.Scan0);
               byte* dstPtr = (byte*)(dstData.Scan0);
               for (int i = 0; i < dstData.Height; i++)  {
                   for (int j = 0; j < dstData.Width - 1; j++)  {  // do all the colors, the -1 is a kludge until I figure out the unused areas
                       for (int k = 0; k < 3; k++)  {
                           if (ints == 0)  {
                               *(dstPtr + k) = *(srcPtr + k);
                               continue;
                           }
                           int ires = *(srcPtr + k);
                           if (ints > 0)                             {
                               ires = *(srcPtr + k) + (((255 - *(srcPtr + k)) * ints) / 100);
                           }
                           else  {
                               ires = *(srcPtr + k) + ((*(srcPtr + k) * ints) / 100);
                           }
                           if (ires > 255) ires = 255; // int operations are not guaranteed to be +-1
                           if (ires < 0) ires = 0;
                           *(dstPtr + k) = (byte)ires;
                       }
                       srcPtr += srcBytes;
                       dstPtr += dstBytes;
                   }
                   srcPtr += srcData.Stride - srcData.Width * srcBytes;
                   dstPtr += dstData.Stride - dstData.Width * dstBytes;
               }

It seems to work in my app, but I haven't tested it on many pictures.

thanks,

Walter

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...