Subtract two pictures

Smileon
01-13-2005, 11:31 PM
Hi!

Does anyone know how to subtract two pictures one from another...
I am doing it with a simple FOR.... but it is a bit too slow? Is there a better way??? Oh yes, I have the picture data in arrays of bytes...

THANK YOU everyone!!!!!!!

zelg37
01-15-2005, 12:54 AM
Are you using GetDIBits and SetDIBits?
"The basic idea is that you access the actual bitmap that makes up the picture. You can do this indirectly by using the API functions GetDIBits and SetDIBits which extract a bitmap into an array and copy an array to a bitmap respectively, but you can do it directly if you had an array that pointed to the actual memory used by the bitmap."
This is called the DMA (Direct Memory Access) method and here's BillSoo's thread in the Code Library:
http://www.xtremevbtalk.com/t25347.html

A derivative example based on BillSoo's class and using RGB long color pixel manipulation is attached on this post:
http://www.xtremevbtalk.com/showpost.php?p=859095

eXeption
01-15-2005, 01:20 AM
This is giving me satisfactory results:

' Let there be two pictureboxes namely Picture1 amd Picture2
StretchBlt Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, vbMergePaint
StretchBlt Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbNotSrcCopy

zelg37
01-15-2005, 01:33 AM
I thought about blit-ing, but he said he wanted to use a byte array. :-\

If he wants to play around with blit-ing using other ROP (Raster OPerations) codes besides MergePaint and NotSrcCopy, there's Bitblt ROPCodes sampler attached to this post:
http://www.xtremevbtalk.com/showpost.php?p=624631

Also, the SetStretchBltMode API can sometimes be used to improve picture quality when using Stretchblt..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum