Sunday, 15 September 2013

graphics - How to display part of an image using a for loop from a picturebox array -



graphics - How to display part of an image using a for loop from a picturebox array -

there may simple reply have tried quite few things , nil seems work unless manually display images want utilize sub other pictures prepare later 1 time display these images. code follows

private sub updatestandardtoolbar() 'draws sprites pictureboxes dim bit new bitmap(gridsize, gridsize) dim dest_rect rectangle = new rectangle(0, 0, gridsize, gridsize) dim integer = 0 ' associate graphics object bitmap dim gr graphics = graphics.fromimage(bit) y integer = 0 standardnum.y x integer = 0 standardnum.x phone call getsrcrect(x, y) 'copy part of image. gr.drawimage(bmpstandardtile, dest_rect, src_rect, graphicsunit.pixel) 'display result. pb(i).image = bit += 1 next next end sub

the problem code pictureboxes (pb()) displays same image lastly 1 on image. standardnum.x , standardnum.y variables hold 3 , 1 respectively. bmpstandardtile image want re-create , dest_rect , src_rect self explanatory =). helps appreciated.

oh. found reply own problem after looking @ why pictureboxes displays same image. here code , how fixed if else has similar or same problem.

private sub updatestandardtoolbar() 'draws sprites pictureboxes dim bit bitmap dim dest_rect rectangle = new rectangle(0, 0, gridsize, gridsize) dim integer = 0 ' associate graphics object bitmap 'dim gr graphics 'for u integer = 0 maxpics ' bit = new bitmap(gridsize, gridsize) 'next y integer = 0 standardnum.y x integer = 0 standardnum.x bit = new bitmap(gridsize, gridsize) dim gr graphics = graphics.fromimage(bit) phone call getsrcrect(x, y) 'copy part of image. gr.drawimage(bmpstandardtile, dest_rect, src_rect, graphicsunit.pixel) 'display result. pb(i).image = bit += 1 next next end sub

the reply simple. silly me. forgot clear bitmap image not alter image lastly picturebox using.

bit = new bitmap(gridsize, gridsize)

anyway learnt mistakes =)

arrays graphics vb.net-2010 picturebox

No comments:

Post a Comment