A-man Posted May 9, 2012 Share Posted May 9, 2012 If i have something like image1 := loadbitmap('path') (pretend its a real path), will image2 := image1 make image2 a copy of the first bitmap? I have a code with that setup and I'm not sure it's working, and don't know how to test whether or not it is. Hopefully someone here would know. I'm pretty sure loadbitmap just returns an integer which is an index to the image it is storing, so it should work in theory. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted May 9, 2012 Share Posted May 9, 2012 (edited) My bad... thought load bitmap would be like doing bitmap from string Also check out the wiki - http://wiki.scar-divi.com/index.php?title=LoadBitmap Edited May 10, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted May 10, 2012 Share Posted May 10, 2012 Heres a simple procedure [scar] Function CopyBitmap(BMP: Integer): Integer; Var W,H: Integer; S: String; Begin GetBitmapSize(BMP, W, H); S := BitmapToString(BMP); Result := BitmapFromString(W, H, S); end; Var BMP, BMPcopy: Integer; begin BMP := BitmapFromString(100,100,''); CopyClientToBitmap(BMP, 0, 0, 99 ,99); // Test Orginal Bitmap BMPcopy := CopyBitmap(BMP); // create a copy FastDrawClear(BMP, clBlack); // Fill orginal bitmap black DebugBitmap(BMP); // display orginal all black wait(400); DebugBitmap(BMPcopy); // display the copy which should show the client Freebitmap(BMP); // free bitmaps Freebitmap(BMPcopy); end. [/scar] ---------- Post added at 03:55 AM ---------- Previous post was at 03:00 AM ---------- This actually copy's the bitmap into a new bitmap so if you wanted to edit the first bitmap without loosing the original you could. if you did what you said, the original bitmap would be edited when ever your edited the copy, an example is below. If i free the original bitmap before i debug the copy of the bitmap i get an error of bitmap not assigned. Thi9s is because you are working with bitmap indexs and not the entire data fro the bitmap. [scar] Var BMP, BMPcopy: Integer; begin BMP := BitmapFromString(100,100,''); CopyClientToBitmap(BMP, 0, 0, 99 ,99); // Test Orginal Bitmap BMPcopy := BMP; FreeBitmap(BMP); debugbitmap(BMPcopy); end. [/scar] Quote Link to comment Share on other sites More sharing options...