<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [SOLVED] Issue related with Picture displaying in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249107#M5460</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I show an image programmatically in my Dialog picture&lt;BR /&gt;Problem is that picture result is a black frame&lt;BR /&gt;&lt;BR /&gt;Here is my code&lt;BR /&gt;&lt;BR /&gt;resource file
&lt;PRE&gt;'GDLG'	32500	Modal   0	 0	    425   330		"Settings" {
/* [  1] */ Picture            19    12     64    64  400    ClientEdge		/* user picture */
}&lt;/PRE&gt;
&lt;PRE&gt;'DLGH'  32500  DLG_32500_Settings {
1	""							userImage
}&lt;/PRE&gt;
C++ code&lt;BR /&gt;
&lt;PRE&gt;NewDisplay::NativeImage SettingsDialog::setNativeImageSize(const NewDisplay::NativeImage&amp;amp; 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-&amp;gt;setNativeImageSize(myGXImage.ToNativeImage());
	myGXImage = GX::Image (tmpNativeImage);

	const void* dgPicture = myGXImage.ToDGPicture ();  
	DGSetItemImage (IID_SETTINGS, IDP_USER_IMAGE, DG::Picture (dgPicture));

}
&lt;/PRE&gt;
I want to display always with a static size w-64, h-64, x-19, y-12&lt;BR /&gt;Result always a black frame &lt;BR /&gt;Please look at attached picture&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="picture_issue.png" style="width: 444px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/8545i4EB642BB6EB9F2DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="picture_issue.png" alt="picture_issue.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2023 11:37:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-01T11:37:17Z</dc:date>
    <item>
      <title>[SOLVED] Issue related with Picture displaying</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249107#M5460</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I show an image programmatically in my Dialog picture&lt;BR /&gt;Problem is that picture result is a black frame&lt;BR /&gt;&lt;BR /&gt;Here is my code&lt;BR /&gt;&lt;BR /&gt;resource file
&lt;PRE&gt;'GDLG'	32500	Modal   0	 0	    425   330		"Settings" {
/* [  1] */ Picture            19    12     64    64  400    ClientEdge		/* user picture */
}&lt;/PRE&gt;
&lt;PRE&gt;'DLGH'  32500  DLG_32500_Settings {
1	""							userImage
}&lt;/PRE&gt;
C++ code&lt;BR /&gt;
&lt;PRE&gt;NewDisplay::NativeImage SettingsDialog::setNativeImageSize(const NewDisplay::NativeImage&amp;amp; 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-&amp;gt;setNativeImageSize(myGXImage.ToNativeImage());
	myGXImage = GX::Image (tmpNativeImage);

	const void* dgPicture = myGXImage.ToDGPicture ();  
	DGSetItemImage (IID_SETTINGS, IDP_USER_IMAGE, DG::Picture (dgPicture));

}
&lt;/PRE&gt;
I want to display always with a static size w-64, h-64, x-19, y-12&lt;BR /&gt;Result always a black frame &lt;BR /&gt;Please look at attached picture&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="picture_issue.png" style="width: 444px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/8545i4EB642BB6EB9F2DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="picture_issue.png" alt="picture_issue.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 11:37:17 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249107#M5460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-01T11:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Issue related with Picture displaying</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249108#M5461</link>
      <description>As I see the problem is that you use NativeImage::DrawImage on the wrong way. You need something similar to this:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;float wScale = 64.0f / image.GetWidth();
float hScale = 64.0f / image.GetHeight();
context.DrawImage (image, wScale, hScale, 0.0, 0.0, 0.0, false);
&lt;/PRE&gt;

The second and third parameters are the scaling values, which you should use to make your image fit into the drawing area.&lt;BR /&gt;
The x=19 and y= 12 positions are not needed here, they are already specified in the resource file.</description>
      <pubDate>Mon, 16 Mar 2015 13:52:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249108#M5461</guid>
      <dc:creator>Tamas Zolnai</dc:creator>
      <dc:date>2015-03-16T13:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Issue related with Picture displaying</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249109#M5462</link>
      <description>&lt;BLOCKQUOTE&gt;Tamás wrote:&lt;BR /&gt;As I see the problem is that you use NativeImage::DrawImage on the wrong way. You need something similar to this:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;float wScale = 64.0f / image.GetWidth();
float hScale = 64.0f / image.GetHeight();
context.DrawImage (image, wScale, hScale, 0.0, 0.0, 0.0, false);
&lt;/PRE&gt;

The second and third parameters are the scaling values, which you should use to make your image fit into the drawing area.&lt;BR /&gt;
The x=19 and y= 12 positions are not needed here, they are already specified in the resource file.&lt;/BLOCKQUOTE&gt;

Thank you for the help. Now it works ))</description>
      <pubDate>Tue, 17 Mar 2015 13:27:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-Issue-related-with-Picture-displaying/m-p/249109#M5462</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-17T13:27:36Z</dc:date>
    </item>
  </channel>
</rss>

