<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>canvas Archives - Dragonsoft Technology View</title>
	<atom:link href="https://blog.dragonsoft.us/tag/canvas/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.dragonsoft.us/tag/canvas/</link>
	<description>Talk about Technologies, Software Architecture and Management</description>
	<lastBuildDate>Thu, 04 Sep 2008 14:17:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blog.dragonsoft.us/wp-content/uploads/2022/04/logo-main-bw-150x150.png</url>
	<title>canvas Archives - Dragonsoft Technology View</title>
	<link>https://blog.dragonsoft.us/tag/canvas/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">2577970</site>	<item>
		<title>TIPS: Draw Image From TImageList</title>
		<link>https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/</link>
					<comments>https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/#respond</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Thu, 28 Aug 2008 18:56:43 +0000</pubDate>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[load imagelist from resource file]]></category>
		<category><![CDATA[timage]]></category>
		<category><![CDATA[timagelist]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=339</guid>

					<description><![CDATA[<p>This question is coming back and again. I have a TImage in many form which shows the status of the item. It requires status image being changed when it is changed. I do not want to use several instances of the TImage on the form. Instead I would like to<a class="moretag" href="https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/">TIPS: Draw Image From TImageList</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This question is coming back and again.</p>
<blockquote><p>I have a TImage in many form which shows the status of the item. It requires status image being changed when it is changed. I do not want to use several instances of the TImage on the form. Instead I would like to use TImageList to store and share them.</p></blockquote>
<p>Yes, you can. But there are some quirks you have to consider when doing so.</p>
<p>Let&#8217;s say you have state images and you have to draw a different one based on the state.</p>
<p>Let&#8217;s say you have placed Image list and an Image on your form and populated the list with few state images</p>
<pre class="brush: delphi; title: ; notranslate">var
  MyImageList: TImageList;
  MyImage: TImage;</pre>
<h3>Canvas</h3>
<p>That is probably the easiest case. Lets draw an image on canvas of some control (OwnerDraw situation) and also center it. X, Y are top left corner of the future image and Width is a width of the rectangle we want to center image in.<br />
MyImageIndex is an index of the image in the Image List.</p>
<pre class="brush: delphi; title: ; notranslate">MyImageList.Draw(Canvas, X + Width div 2 - MyImageList.Width div 2, Y, MyImageIndex, dsNormal, itImage);</pre>
<h3>TImage</h3>
<p>Being a little bit more complex, it does require some extra code.</p>
<pre class="brush: delphi; title: ; notranslate">// Make sure that any prior state is cleared.
// If you do not do that with transparency enabled, you would see
// images on top of each other
MyImage.Picture.Bitmap := nil;
// Make sure that transparency pixel in the image is taken
// in consideration
MyImage.Picture.Bitmap.TransparentMode := tmFixed;
MyImage.Picture.Bitmap.TransparentColor := clWhite;
// Load image from the Image list into TImage
MyImageList.GetBitmap(MyImageIndex, MyImage.Picture.Bitmap);</pre>
<h3>Can I use resource file?</h3>
<p>Would you like to keep images in the file?</p>
<pre class="brush: delphi; title: ; notranslate">// Store it once
WriteComponentResFile(&#039;MyImageList.dat&#039;, MyImageList);
// Use it later
ReadComponentResFile(&#039;MyImageList.dat&#039;, MyImageList);</pre>
<p>Not that difficult after all.</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/">TIPS: Draw Image From TImageList</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/08/28/tips-draw-image-from-timagelist/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">339</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Minified using Disk
Database Caching 18/83 queries in 0.100 seconds using Disk

Served from: blog.dragonsoft.us @ 2026-06-22 16:49:37 by W3 Total Cache
-->