2015-02-17 03:55 PM - last edited on 2023-08-01 01:38 PM by Doreena Deng
IO::Location locationToPic ("d:\\Pictures\\67-hero.jpg"); const void* dgPicture = GX::Image (locationToPic).ToDGPicture (); DGSetItemImage (IID_SETTINGS, 400, DG::Picture (dgPicture));After above code I want to change width and height of picture.
2015-02-18 09:23 AM
//---------------------------------------------------------------------------- IO::Location locationToPic ("d:\\Pictures\\67-hero.jpg"); GX::Image myGXImage (locationToPic); // resize the picture NewDisplay::NativeImage tmpNativeImage = ResizeNativeImage (myGXImage.ToNativeImage (), 64 /* new width */); myGXImage = GX::Image (tmpNativeImage); // get the size of the resized picture UInt32 picWidth = myGXImage.GetWidth (); UInt32 picHeight = myGXImage.GetHeight (); // get actual size of the dialog item short left, top, right, bottom; DGGetItemRect (IID_SETTINGS, 400, &left, &top, &right, &bottom); // change dialog item size to equal the picture size short hGrow = (right - left) - picWidth; short vGrow = (bottom - top) - picHeight; DGGrowItem (IID_SETTINGS, 400, hGrow, vGrow); // set the picture const void* dgPicture = myGXImage.ToDGPicture (); DGSetItemImage (IID_SETTINGS, 400, DG::Picture (dgPicture)); //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // Helper function to resize image //---------------------------------------------------------------------------- NewDisplay::NativeImage ResizeNativeImage (const NewDisplay::NativeImage& image, Int32 newWidth) { if (image == NULL) return image; float scale = newWidth / image.GetWidth (); Int32 newHeight = image.GetHeight () * scale; NewDisplay::NativeImage retVal (newWidth, newHeight, image); NewDisplay::NativeContext context = retVal.GetContext (); context.DrawImage (image, scale, scale, 0.0, 0.0, 0.0, false); retVal.ReleaseContext (context); return retVal; } //----------------------------------------------------------------------------
2015-02-18 06:13 PM