C# copy paste an image region into another image -
i trying write utility class permits automatic resizing of images tilebale. let's there srcbitmap copy region given rectangle srcregion. want paste (pixel information wise) region image called bitmap destbitmap, in destination region rectangle destregion. know how region source , put bitmap object, haven't yet been able find how paste bitmap object in region, inside another, bigger bitmap object.
is there quick way this? (without gdi , without delving byte array of bitmaps). here snippet should clarify goal
private static void copyregionintoimage(bitmap srcbitmap, rectangle srcregion, bitmap destbitmap, rectangle destregion) { // required region destination bitmap region = copy(srcbitmap, srcregion); }
use :
public static void copyregionintoimage(bitmap srcbitmap, rectangle srcregion,ref bitmap destbitmap, rectangle destregion) { using (graphics grd = graphics.fromimage(destbitmap)) { grd.drawimage(srcbitmap, destregion, srcregion, graphicsunit.pixel); } }
Comments
Post a Comment