View Full Version : dotNet textureBrush?
I want to use an image and draw it using GDI. The image is 1 pixel wide and I want to be able to tile it as many times as I like.
Using graphics.drawImage theImage aScaledRactangle
I get the image fading off. Not sure why it would do this but it does. I can't see a way to make it tile it using this method. Using a textureBrush I can set the wrapMode to tile. I can't for the life of me sort out how to create one in Max script.
Here is one of my attempts.
bm=(dotNetClass "system.drawing.image").fromFile @"someImage"
(dotNetClass "System.Drawing.textureBrush") bm
What am I missing? and, am I going down the right road?
I should mention that I have also tried this..
and it works but controlling the length doesn't appear to be logical. I get strange lengths.
I have a solution, doesn't make a whole lot of sense but it is working and I don't have time to mess with it more.
Still would like to know how to make a textureBrush.
09-23-2009, 11:50 PM
you can use the FillRectangle function of a graphics object and pass the textureBrush as the brush argument. You can set the WrapMode of the texturebrush to tile if you like but it seems to be the default anyway. i didnt set the interpolation mode at all. see below: (
rollout testRoll "testRoll"
dotnetcontrol btn "System.Windows.Forms.Button" width:280 height:280
on btn Click sender arg do
image = dotnetobject "System.Drawing.Bitmap" (getDir #maxroot + @"\ui\icons\CreateTypes_16i.bmp")
texture = dotnetobject "System.Drawing.TextureBrush" image
--texture.WrapMode = texture.WrapMode.Tile
graphics = btn.CreateGraphics()
graphics.FillRectangle texture btn.Bounds
createDialog testRoll width:300 height:300
) you're not restricted to the FillRectangle though. you can fill any of the graphics Fill functions like FillEllipse etc
I wrote the above based off the reference @ MSDN:
This is exactly what I have tried. OK, thanks, frustrating when it looks just the same as tests that I have done. I will see if that is any better or worse then what I have now. I managed to get it working with graphics.drawImage and setting the InterpolationMode to NearestNeighbor but I had to do some strange math to get it to fill the correct rectangle. Works so I'm not worried about it.
09-24-2009, 12:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.