[SOLVED] How to programmatically change Picture size
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-02-17
03:55 PM
- last edited on
‎2023-08-01
01:38 PM
by
Doreena Deng
‎2015-02-17
03:55 PM
Hi
My goal is to change Picture sizes in my C++ code.
Here is my code
My goal is to change Picture sizes in my C++ code.
Here is my code
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.
Labels:
- Labels:
-
Add-On (C++)
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-02-18 09:23 AM
‎2015-02-18
09:23 AM
Hi,
I wrote you an example code to show how to resize the image or the Picture dialog item:
Hope it helps
Regards,
Tibor
I wrote you an example code to show how to resize the image or the Picture dialog item:
//---------------------------------------------------------------------------- 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; } //----------------------------------------------------------------------------
Hope it helps

Regards,
Tibor
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2015-02-18 06:13 PM
‎2015-02-18
06:13 PM
Thank you for the answer!
This is what I needed!
This is what I needed!