1. 1.
    -1
    program kodu lazım panpalar bi el atın...
    ···
  2. 2.
    +1
    *123#
    ···
  3. 3.
    -1
    @2 yarın okul servisine geç kalacaksın yat uyu
    ···
  4. 4.
    +1
    resizing

    this next set of code is a slightly longer and more complex. the main reason this code is longer is because this resize function will keep the height and width proportional.

    to start with we see that the input parameters are the image to resize (system. drawing.image) and the size (system. drawing.size). also in this set of code are a few variables we use. the first two are the source height and width which is used later. and there are 3 other variables to calculate the proportion information.

    private static image resizeimage(image imgtoresize, size size)
    {
    int sourcewidth = imgtoresize. width;
    int sourceheight = imgtoresize. height;

    float npercent = 0;
    float npercentw = 0;
    float npercenth = 0;
    }
    the next step is to actually figure out what the size of the resized image should be. the first step is to calculate the percentages of the new size compared to the original. next we need to decide which percentage is smaller because this is the percent of the original image we will use for both height and width. and now we calculate the number of height and width pixels for the destination image.

    npercentw = ((float)size. width / (float)sourcewidth);
    npercenth = ((float)size. height / (float)sourceheight);

    if (npercenth < npercentw)
    npercent = npercenth;
    else
    npercent = npercentw;

    int destwidth = (int)(sourcewidth * npercent);
    int destheight = (int)(sourceheight * npercent);
    the final thing to do is create the bitmap (system. drawing.bitmap) which we will draw the resized image on using a graphics (system. drawing.graphics) object. i also set the interpolation mode, which is the algorithm used to resize the image. i prefer highqualitybicubic, which from my testing seems to return the highest quality results. and just to clean up a little i dispose the graphics object.

    bitmap b = new bitmap(destwidth, destheight);
    graphics g = graphics. fromimage((image)b);
    g.interpolationmode = interpolationmode. highqualitybicubic;

    g.drawimage(imgtoresize, 0, 0, destwidth, destheight);
    g.dispose();
    and this gives us the final code.

    private static image resizeimage(image imgtoresize, size size)
    {
    int sourcewidth = imgtoresize. width;
    int sourceheight = imgtoresize. height;

    float npercent = 0;
    float npercentw = 0;
    float npercenth = 0;

    npercentw = ((float)size. width / (float)sourcewidth);
    npercenth = ((float)size. height / (float)sourceheight);

    if (npercenth < npercentw)
    npercent = npercenth;
    else
    npercent = npercentw;

    int destwidth = (int)(sourcewidth * npercent);
    int destheight = (int)(sourceheight * npercent);

    bitmap b = new bitmap(destwidth, destheight);
    graphics g = graphics. fromimage((image)b);
    g.interpolationmode = interpolationmode. highqualitybicubic;

    g.drawimage(imgtoresize, 0, 0, destwidth, destheight);
    g.dispose();

    return (image)b;
    }
    Tümünü Göster
    ···
  5. 5.
    -1
    @5 eyw panpa
    ···
  6. 6.
    0
    ya bi gibtir git ya.
    yok böyle bişi amk. ilkokullu program yazıyor.
    ···