|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reference Set or Copy?lock the bits, re-arrange the graphics, unlock the bits, and re-assign the bitmap to the image with: picturebox1->image = myBitmap; Everything works great! Question: Is the assignment statement above a copy function, or is picturebox1->image a reference to myBitmap? I know if I change the code as such: picturebox1->image = myBitmap; delete [] myBitmap; I get invalid object errors (implying picturebox1 is a reference). But, if I relock the bitmap, re-arrange the bits again, and unlock them without the re-assignment, the image never updates (even when I minimize/maximize to force a repaint) - implying picturebox1 has a copy of the data). So what exactly is going on here? (By the way, by using pictureboxes and lockbits/unlockbits, I can display & modify images without creating a graphics object or dealing with 'Paint' events - pretty cool!). Hello, bern11!
b> picturebox1->image = myBitmap; b> Everything works great! b> Question: Is the assignment statement above a copy function, or is b> picturebox1->image a reference to myBitmap? I know if I change the code b> as such: b> picturebox1->image = myBitmap; b> delete [] myBitmap; b> I get invalid object errors (implying picturebox1 is a reference). Yes, there is no copying, but reference set. b> But, if I relock the bitmap, re-arrange the bits again, and unlock them b> without the re-assignment, the image never updates (even when I b> minimize/maximize to force a repaint) - implying picturebox1 has a copy b> of the data). . Did you try invalidating picturebox, like picturebox1->Invalidate(); Or even better you can do bitmap assignment again. picturebox1->image = myBitmap; is not simple property set. Setter is doing some job here, like invalidating, adjustring size etc.... |
|||||||||||||||||||||||