2015-02-26 08:17 AM - last edited on 2023-08-01 01:37 PM by Doreena Deng
'GDLG' 32500 Modal 0 0 425 330 "Settings" { /* [ 1] */ Picture 19 12 64 64 400 ClientEdge /* user picture */ }
'DLGH' 32500 DLG_32500_Settings { 1 "" userImage }C++ code
NewDisplay::NativeImage SettingsDialog::setNativeImageSize(const NewDisplay::NativeImage& image) { if (image == NULL) return image; NewDisplay::NativeImage retVal (64, 64, image); NewDisplay::NativeContext context = retVal.GetContext (); context.DrawImage (image, 19, 12, 0.0, 0.0, 0.0, false); retVal.ReleaseContext (context); return retVal; } void SettingsDialog::setDefaultImage(const char* targetPath) { IO::Location locationToPic(targetPath); GX::Image myGXImage (locationToPic); NewDisplay::NativeImage tmpNativeImage = this->setNativeImageSize(myGXImage.ToNativeImage()); myGXImage = GX::Image (tmpNativeImage); const void* dgPicture = myGXImage.ToDGPicture (); DGSetItemImage (IID_SETTINGS, IDP_USER_IMAGE, DG::Picture (dgPicture)); }I want to display always with a static size w-64, h-64, x-19, y-12
2015-03-16 02:52 PM
float wScale = 64.0f / image.GetWidth(); float hScale = 64.0f / image.GetHeight(); context.DrawImage (image, wScale, hScale, 0.0, 0.0, 0.0, false);The second and third parameters are the scaling values, which you should use to make your image fit into the drawing area.
2015-03-17 02:27 PM
Tamás wrote:Thank you for the help. Now it works ))
As I see the problem is that you use NativeImage::DrawImage on the wrong way. You need something similar to this:float wScale = 64.0f / image.GetWidth(); float hScale = 64.0f / image.GetHeight(); context.DrawImage (image, wScale, hScale, 0.0, 0.0, 0.0, false);The second and third parameters are the scaling values, which you should use to make your image fit into the drawing area.
The x=19 and y= 12 positions are not needed here, they are already specified in the resource file.