How to change the height and width of a png image dynamically using vc++?



  • Hi,

    I m trying to load a png image by giving the dimension of my own.

    CImage Image;
    Image.Load (L"D:\\Images\\PNG_Images\\Image7.png");

    But here what happens is that I m not able to give my own dimensions.My code requires constant changing of dimensions of the image.[code="cpp"]
    I tried using libpng.lib in my code.But I dono the keywords for loading the png image after including the lib.

    I m using Visual Studio 2010. I m developing in vc++.

    How do I load and change the height and width of a png image?

    Thankx a ton in advance....



  • Bei CImage kann man Höhe und Breite mit StretchBlt skalieren:

    CString srcfile; //path to jpg source
    int hThumb=100; //height of thumbnail
    CImage img1,img2;
    img1.Load(srcfile);
    int h=img1.GetHeight();
    int w=img1.GetWidth();
    int tnh=hThumb;
    int tnw=hThumb*w/h;
    int bpp=img1.GetBPP();
    img2.Create(tnw,tnh,bpp);
    HDC h2=img2.GetDC(); //this returns undefined ?
    SetStretchBltMode(h2,HALFTONE);
    img1.StretchBlt(h2,0,0,tnw,tnh,SRCCOPY);
    img2.Save("tn_"+srcfile);
    img2.ReleaseDC();
    

    ref: http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/674a0bf4-cad3-44be-99f5-10a5e74c1022

    Qualitativ soll Gdiplus::Image() (<gdiplus.h>) besser geeignet sein.

    MSDN - Cropping and Scaling Images (Windows)
    http://msdn.microsoft.com/en-us/library/windows/desktop/ms533828(v=vs.85).aspx


Log in to reply