<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Graphics</title>
        <link>http://geekswithblogs.net/TimH/category/9720.aspx</link>
        <description>Graphics</description>
        <language>en-NZ</language>
        <copyright>Tim Huffam</copyright>
        <managingEditor>timhuffam@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>WPF 3D - programmatically adding an image brush</title>
            <link>http://geekswithblogs.net/TimH/archive/2010/07/24/wpf-3d---programmatically-adding-an-image-brush.aspx</link>
            <description>&lt;p&gt;
&lt;/p&gt;&lt;p&gt; &lt;/p&gt;

&lt;div style="margin: 0px"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt"&gt;If you are programmatically assigning an image as a DiffuseMaterial to your 3D model, then you need to make sure that you have created TextureCoordinates. &lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;font size="2"&gt;&lt;span style="font-size: 10pt"&gt;I was using some sample code that created a 3D object - and tried to change the brush from a color to an image.  The color worked fine, but the image never showed (it was invisible).  The reason was that the sample code only did mesh.Positions.Add() and mesh.TriangleIndicies.Add().  When I added the appropriate mesh.TextureCoordinates.Add() lines the image then showed.  eg:&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font size="+0"&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;MeshGeometry3D&lt;/span&gt;&lt;/font&gt; mesh = &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;MeshGeometry3D&lt;/span&gt;&lt;/font&gt;();&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.Positions.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point3D&lt;/span&gt;&lt;/font&gt;(1, 1, 1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.Positions.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point3D&lt;/span&gt;&lt;/font&gt;(1, 1, -1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.Positions.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point3D&lt;/span&gt;&lt;/font&gt;(-7, 1, -1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.Positions.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point3D&lt;/span&gt;&lt;/font&gt;(-7, 1, 1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(0);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(1);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(2);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(0);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(2);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TriangleIndices.Add(3);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#008000"&gt;&lt;span style="color: green"&gt;// These are the lines you need to allow an image to be painted onto the 3d model&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TextureCoordinates.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;ne&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;w&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point&lt;/span&gt;&lt;/font&gt;(0, 0));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TextureCoordinates.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;ne&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;w&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point&lt;/span&gt;&lt;/font&gt;(0, 1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TextureCoordinates.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;ne&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;w&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point&lt;/span&gt;&lt;/font&gt;(1, 1));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;mesh.TextureCoordinates.Add(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;ne&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;w&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Point&lt;/span&gt;&lt;/font&gt;(1, 0));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;ImageBrush&lt;/span&gt;&lt;/font&gt; imgBrush = &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;ImageBrush&lt;/span&gt;&lt;/font&gt;(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;BitmapImage&lt;/span&gt;&lt;/font&gt;(&lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;/font&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Uri&lt;/span&gt;&lt;/font&gt;(&lt;font color="#a31515"&gt;&lt;span style="color: rgb(163,21,21)"&gt;"pack://siteoforigin:,,,/&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#a31515"&gt;&lt;span style="color: rgb(163,21,21)"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#a31515"&gt;&lt;span style="color: rgb(163,21,21)"&gt;myimage.png"&lt;/span&gt;&lt;/font&gt;)));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#008000"&gt;&lt;span style="color: green"&gt;//GeometryModel3D geometry = new GeometryModel3D(mesh, new DiffuseMaterial(Brushes.Green)&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#008000"&gt;&lt;span style="color: green"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;span style="font-family: Courier New"&gt;&lt;span style="color: green"&gt;);  // this line works without the TextureCoordinates&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;GeometryModel3D&lt;/span&gt;&lt;/font&gt; geometry = &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;GeometryModel3D&lt;/span&gt;&lt;/font&gt;(mesh, &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;DiffuseMaterial&lt;/span&gt;&lt;/font&gt;(imgBrush));&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;geometry.Transform = &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Transform3DGroup&lt;/span&gt;&lt;/font&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;&lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Model3DGroup&lt;/span&gt;&lt;/font&gt; group = &lt;font color="#0000ff"&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;/font&gt; &lt;font color="#2b91af"&gt;&lt;span style="color: rgb(43,145,175)"&gt;Model3DGroup&lt;/span&gt;&lt;/font&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;group.Children.Add(geometry);&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;HTH&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin: 0px"&gt;&lt;span style="font-family: Courier New"&gt;Tim&lt;/span&gt;&lt;/div&gt; &lt;img src="http://geekswithblogs.net/TimH/aggbug/141049.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Tim Huffam</dc:creator>
            <guid>http://geekswithblogs.net/TimH/archive/2010/07/24/wpf-3d---programmatically-adding-an-image-brush.aspx</guid>
            <pubDate>Sat, 24 Jul 2010 11:39:37 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/TimH/comments/141049.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/TimH/archive/2010/07/24/wpf-3d---programmatically-adding-an-image-brush.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/TimH/comments/commentRss/141049.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/TimH/services/trackbacks/141049.aspx</trackback:ping>
        </item>
        <item>
            <title>How to fade image layers using Gimp gradient/blend tool</title>
            <link>http://geekswithblogs.net/TimH/archive/2009/03/10/how-to-fade-image-layers-using-gimp-gradientblend-tool.aspx</link>
            <description>&lt;p&gt;This post will explain how to do fading (fade out a layer) in Gimp.&lt;/p&gt;
&lt;p&gt;Assuming you have an image open...&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Add a new layer &lt;/li&gt;
    &lt;li&gt;Draw the part you want faded &lt;/li&gt;
    &lt;li&gt;Right click on the layer in the Layers panel/window and select 'Add Layer Mask', then click on Add on the Add Layer Mask dialog (making sure the default value of 'White (full opacity)' is selected). &lt;/li&gt;
    &lt;li&gt;Select the Blend/Gradient tool and set the Gradient to 'FG to GB(RGB)' . &lt;/li&gt;
    &lt;li&gt;On the layer click and drag a line where you want the gradient (fade) to start and finish.  The first click is where it will be faded out and the second click is where it will start to fade. &lt;/li&gt;
    &lt;li&gt;Right click on the layer in the Layers panel/window and select 'Apply Layer Mask'. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That's it.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/TimH/aggbug/129953.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Tim Huffam</dc:creator>
            <guid>http://geekswithblogs.net/TimH/archive/2009/03/10/how-to-fade-image-layers-using-gimp-gradientblend-tool.aspx</guid>
            <pubDate>Tue, 10 Mar 2009 14:49:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/TimH/comments/129953.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/TimH/archive/2009/03/10/how-to-fade-image-layers-using-gimp-gradientblend-tool.aspx#feedback</comments>
            <slash:comments>14</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/TimH/comments/commentRss/129953.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/TimH/services/trackbacks/129953.aspx</trackback:ping>
        </item>
        <item>
            <title>How to make a transparent background/selection on an image using GIMP</title>
            <link>http://geekswithblogs.net/TimH/archive/2006/03/20/72797.aspx</link>
            <description>&lt;ol&gt;
    &lt;li&gt;Open your image. &lt;/li&gt;
    &lt;li&gt;Select the area you want to make transparent.
    &lt;ol&gt;
        &lt;li&gt;Select the appropriate selection tool from the Tool window or the Tools - Selection Tools menu on the Layer window.  I usually use the magic wand/fuzzy select (Select contiguous region) tool or the Select regions by color tool. &lt;/li&gt;
        &lt;li&gt;Click in the region you want selected.  Use shift-click to add more regions/colors.&lt;br /&gt;
        Tip: It's easier if you zoom in (View - Zoom menu) to see finer details of exactly what you're selecting.&lt;/li&gt;
    &lt;/ol&gt;
    &lt;/li&gt;
    &lt;li&gt;In the Layer window (the one showing your image), select Layer - Transparency - Add Alpha Channel.  If this is blanked out then it's already done.  This makes sure your image can store transparency data. &lt;/li&gt;
    &lt;li&gt;Select Edit - Clear.  This makes the selection transparent. &lt;/li&gt;
    &lt;li&gt;Save the file.  &lt;br /&gt;
    Note: If you save it as a PNG file, be sure to select the 'Save colour values from transparent pixels' option in the Save as PNG dialog box.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And that's it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: IE does not support showing PNG transparencies (alpha channels) natively.  There are a few work arounds for this (theres loads to be found on google) - here's MS's &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;294714"&gt;solution&lt;/a&gt;.  However, personally, I find the simplest approach is to save the image as a GIF (which all major browers support transparencies for).&lt;/p&gt;
&lt;p&gt;When saving your image as a GIF from within Gimp, it will prompt you to export it - you can select either Indexed or Greyscale - however, on the next screen (Save as GIF) be sure to check the 'Interlace' option.&lt;/p&gt;
&lt;p&gt;HTH&lt;/p&gt;
&lt;p&gt;Tim&lt;/p&gt; &lt;img src="http://geekswithblogs.net/TimH/aggbug/72797.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Tim Huffam</dc:creator>
            <guid>http://geekswithblogs.net/TimH/archive/2006/03/20/72797.aspx</guid>
            <pubDate>Mon, 20 Mar 2006 14:49:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/TimH/comments/72797.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/TimH/archive/2006/03/20/72797.aspx#feedback</comments>
            <slash:comments>179</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/TimH/comments/commentRss/72797.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/TimH/services/trackbacks/72797.aspx</trackback:ping>
        </item>
    </channel>
</rss>
