CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Mar 2005
    Posts
    23

    Colors Shifting In 24 bit Bitmap.

    Hello,

    I am experiencing some difficulty changing the colors of a bitmap. For each pixel of a bitmap I am assigning it a shade of blue based on its horizontal placement. The function is similar to

    pixel.blue = ((x*v)%n)%256,
    pixel.green = 0,
    pixel.red = 0.

    x: Position from 0 to bitmap.width - 1.
    v: Variation in color [0 to 255].
    n: Maximum number of colors [0 to 255].

    The expected bitmap begins with columns of low intensity blue that progress to high intensity blue and then repeat. However, sometimes there are diagonal columns or no columns, and there are also pixels with shades of just red or just green. From what i have seen it appears that the first part of each row is being misplaced somehow and that the cutoff is not happening at a pixel boundry, resulting in other colors. To further complicate matters, the behavior does not appear if I use pixel.blue = 200 (or any other constant) and is also dependant on the values of v, n, and bitmap.width.

    I have included the mini project that I am using to try to understand the problem. Thank you for your help.

    dremmuel
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured