|
|
"Tim Roberts" <timr@probo.com>
???????:h43d72lq9o6vf1263umhq7hm1hj6dm0b24@4ax.com...
> "Jack" <jl@knight.com> wrote:
>
> "Pointer is byte-based" doesn't really mean anything. Every bitmap is
> just
> a string of bytes. It just so happens that, in a 24-bit DIB, a pixel is
> spread across three bytes.
>
>
> You don't need to allocate any space. The BITMAP structure contains a
> pointer to the bytes of the bitmap.
>
>
> How much C experience do you have? Both of those for loops are infinite
> loops. You aren't bumping your loop counter. Plus, in the second one,
> you're testing the wrong variable.
>
>
> Every pixel in a 24-bit DIB occupies three bytes. So, pixel X,Y is at
>
> ((Y * width) X) * 3
>
> However, there may be padding at the end of each scanline. The actual
> distance from the start of one scanline to the start of the next is in
> bmWidthBytes.
>
> pBitmap->GetBitmap(&bmpX);
> BYTE* bmpBuffer = bmpX.bmBits;
> for (int i = 0; i < bmpX.bmHeight; i) {
> for (int j = 0; j < bmpX.bmWidth; j) {
> int iPixelOffset =
> j * bmpX.bmWidthBytes
> i * bmpX.bmBitsPixel / 8;
> unsigned long pixel = *(unsigned long *)(bmpBuffer iPixelOffset) &
> 0xffffff; <<<<<<<<<<<<<<<<<<<<<<< AV Error
> if (pixel == RGB(255,255,0))
> AfxMessageBox ("Hit it", MB_OK, NULL);
> }
> }
Dear Tim,
I still got a access violation error on the line shown above (accessing
image 0x01800000 offset 0xe1000)
Thanks
Jack
> --
> - Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
|
|