<?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] How to programmatically change Picture size in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246643#M5434</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;&lt;BR /&gt;My goal is to change Picture sizes in my C++ code.&lt;BR /&gt;Here is my code &lt;BR /&gt;
&lt;PRE&gt;IO::Location locationToPic ("d:\\Pictures\\67-hero.jpg"); 
const void* dgPicture = GX::Image (locationToPic).ToDGPicture (); 
DGSetItemImage (IID_SETTINGS, 400, DG::Picture (dgPicture));  
&lt;/PRE&gt;
After above code I want to change width and height of picture.&lt;/DIV&gt;</description>
    <pubDate>Tue, 01 Aug 2023 11:38:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-01T11:38:31Z</dc:date>
    <item>
      <title>[SOLVED] How to programmatically change Picture size</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246643#M5434</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;&lt;BR /&gt;My goal is to change Picture sizes in my C++ code.&lt;BR /&gt;Here is my code &lt;BR /&gt;
&lt;PRE&gt;IO::Location locationToPic ("d:\\Pictures\\67-hero.jpg"); 
const void* dgPicture = GX::Image (locationToPic).ToDGPicture (); 
DGSetItemImage (IID_SETTINGS, 400, DG::Picture (dgPicture));  
&lt;/PRE&gt;
After above code I want to change width and height of picture.&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Aug 2023 11:38:31 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246643#M5434</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-01T11:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically change Picture size</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246644#M5435</link>
      <description>Hi, &lt;BR /&gt;
 &lt;BR /&gt;
I wrote you an example code to show how to resize the image or the Picture dialog item: &lt;BR /&gt;
 
&lt;PRE&gt;//---------------------------------------------------------------------------- 
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, &amp;amp;left, &amp;amp;top, &amp;amp;right, &amp;amp;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&amp;amp; 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; 
} 
//----------------------------------------------------------------------------&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
Hope it helps  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_wink.gif" style="display : inline;" /&gt;  &lt;BR /&gt;
 &lt;BR /&gt;
Regards, &lt;BR /&gt;
Tibor</description>
      <pubDate>Wed, 18 Feb 2015 08:23:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246644#M5435</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-02-18T08:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically change Picture size</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246645#M5436</link>
      <description>Thank you for the answer!&lt;BR /&gt;
This is what I needed!</description>
      <pubDate>Wed, 18 Feb 2015 17:13:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-programmatically-change-Picture-size/m-p/246645#M5436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-02-18T17:13:07Z</dc:date>
    </item>
  </channel>
</rss>

