c# - Evenly positioning of multiple images on bitmap -
i'm trying position number of images onto single fixed size image
. size of fixed image
200 x 200 (pixels). lets assume list<image>
contains 3 images. positioning of first 2 images should next each other , positioned @ top of fixed image
. third image
should rendered on "second" line , centered underneath first 2 images. pattern need repeat number of images in list of images. assuming list contains 4 images, first 2 rendered next each other on first line, , second 2 rendered next each other on second line, , on. here have attempted far, positioning on place:
bitmap finalicon = new bitmap(200, 200); image imgfinalicon = (image)finalicon; using (graphics g = graphics.fromimage(imgfinalicon)) { int xoffset = 0; int item = 1; foreach (image icon in iconlist) { int yoffset = 0; if (item > 2 && (iconlist.count() % 2 != 0)) { yoffset = imgfinalicon.height / 2; } else { yoffset = (imgfinalicon.height / 2) / 2; } g.drawimage(icon, xoffset, yoffset); xoffset += icon.width; item++; } }
iconlist
list of images. please?
as far see don't increase y-offset.
try:
yoffset += icon.height;
after displayed 2 images on top or when displayed centered image below.
and yoffset local , exists in loop, , time set 0, when new loop interation starts. outside loop.
Comments
Post a Comment