Here is an example for C ++ Builder (current documents are completely absent):
int X, Y; TBitmapData bm; // get bitmap data access ! if ( Image1->Bitmap->Map(TMapAccess::maReadWrite, bm) ) { unsigned int* data = (unsigned int*)bm.Data; // ie clear data with alpha color memset(data, 0, Image1->Width * Image1->Height * sizeof(unsigned int)); // test direct pixel access here for (X = 20; X <= 200; X++) { for (Y = 10; Y <= 100; Y++) { //MyBitmap->Pixels[X][Y] = claLime; // does not work anymore ! bm.SetPixel(X, Y, claLime); } } // now write back the result ! Image1->Bitmap->Unmap(bm); } else { MessageDlg("Could not map the image data for direct access.", TMsgDlgType::mtWarning, TMsgDlgButtons() << TMsgDlgBtn::mbOK, 0); }
source share