c# - Need help for merging one image with another image -
suppose programmatically comparing between 2 images. after extracting difference between 2 images suppose store difference in bitmap variable called bmp3
i got code site show how merge difference first image.
suppose have 2 bitmap variables called bmp1 & bmp2. extract programmatically difference between 2 variable called bmp1 & bmp2 , store in bmp3 variable.
now want merge difference bmp1 variable @ same position. got code site , works fine have confusion few line of code.
here code:
bitmap bcomb = new bitmap(bmp3.width, bmp3.height); using (graphics g = graphics.fromimage(bcomb)) { g.drawimage(this.picturebox1.image, 0, 0, bcomb.width, bcomb.height); g.drawimage(bmp3, 0, 0, bcomb.width, bcomb.height); } this.picturebox4.image = bcomb; the meaning of line is
bitmap bcomb = new bitmap(bmp3.width, bmp3.height); bcom new variable have same size of bmp3....... right ?
the meaning of line g.drawimage(this.picturebox1.image, 0, 0, bcomb.width, bcomb.height); ?
we writing picbox1 content bcom variable 0,0 coordinate....am right ?
again writing bmp3 content bcom variable 0,0 coordinate again....am right ?
this last line making confusion me. why write bmp3 variable content bcom variable 0,0 coordinate again....am right ?
if write both 0,0 coordinate again bcom variable pic should on lap on each other output coming right. how being possible.
i need understand couple of line. please discuss line in detail , why 0,0 coordinate used. please me understand code. thanks
1. bcomb new variable have same size of bmp3 ....... right ?
yes , it's bitmap size of bmp3 we'll use draw other stuff on contains empty pixels , nothing more !
2.
using (graphics g = graphics.fromimage(bcomb)) this line gives ability draw whatever need on bcomb can bitmap or rectangle or !
3.
g.drawimage(this.picturebox1.image, 0, 0, bcomb.width, bcomb.height); here draws this.picturebox1.image bitmap (bcomb) point (0,0) (bcomb.width,bcomb.height) contain whole bitmap indeed
4.
g.drawimage(bmp3, 0, 0, bcomb.width, bcomb.height); bmp3 being drawn bcomb here again point (0,0) (bcomb.width,bcomb.height)
the bitmaps being drawn on each other same point , same size , point if contain transparent pixels result combination of bitmaps , otherwise see bmp3 drawn later , no clue of first image , , use (0,0) because it's beginning point of our bitmap , use other point draw our stuff in way leave pixels behind why ? :)
- update : it's totally possible draw images on each other , you're right if have transparent pixels result marge , mentioned if last bitmap not contain transparent pixels picture we're gonna see last 1 , won't able see previous bitmaps because pixels over-written last bitmap feel free to use png semi-transparent images , drawing them on top of each other , see result , , i'm afraid , don't know built-in gdi+ function image comparison can
getpixel()function in gdi+ , comparing each pixel 1 bitmap or may use unsafe code , access memory directly totally depends on if want clean , easy way gogetpixel()! may take @ intel's open-cv library image processing , hope helps
Comments
Post a Comment