[Bf-python] image.reload() - Patch

Campbell Barton cbarton at metavr.com
Tue May 25 13:22:22 CEST 2004


Hi Willian, tested image.reload() and cant get it to crash. I actualy 
expected it to with corrupt images but blender handles that nicely too.

I was thinking of making it return a 1/0 depending on weather the 
re-loading was susesfull but I dont think the blender func its self 
tells you weather it works.... hmmm mabe ask the image for a property 
(bit depth or somthing) and if its not there then return 0.

It possible to do this in python too though so Im not that fussed, the 
results of a failed reload are not that bad, or likely  either.

About Using the Gimp for realtime texture painting.

I was working on a job where I realy needed it so I just made a hack.

- Capture the screen area of an image in the gimp
- reload it into blender
- redraw the 3d view.
- repeat.

I had 2 use 2 views, one to capture from that stays at the same view 
level and position and another for editing.
Though this is linux spesific AND needs a lot of screen space (I have 2x 
21" monitors)
 it works surprisingly well for a few resions.

Updates are realtime, ~4fps 256x256.
You can see the cursor in the 3d view before you paint!!  (Was unexpected)
Preview of curves/Levles also shows in the 3D view.
Layes vis/invis shows as well.

A good solution would be to bypass the screen capture function and use 
the gimps tile cache to construct an image as a set res (low res for 
fast loading), then save this to a file as a set interval.
Syncing blender and the gimp would be an issue and there may need to be 
a way of having blender:python trigger the gimp so as to avoid the 
problem where and image is reloading as its being saved.

Anyhow heres my linex script, should work on most linux installs.
_____________________

import os
import string

# Start a program that can be used to set the capture area
# some apps such as gnome apps cant be captured just from using there ID.
os.system('xcalc &')

# Get a windows ID
win = os.popen('xprop | grep WM_CLIENT_LEADER | cut -d# -f2')
win = win.read()[:-1]


import Blender
from Blender import *

while 1:
  os.system('xwd -id ' + win + ' | convert - /tmp/capture.tga ')
 
  img.reload()
  Blender.Window.Redraw(Window.Types['VIEW3D'])

  #time.sleep(0.1)



Willian Padovani Germano wrote:

>Hi Campbell,
>
>(replying personally)
>
>I'm adding Image.reload to cvs, thanks.  You just forgot to add a header file
>that declares that image_changed function, no problem.
>
>But please test it further, for example with images used as tiles and other
>image options, inside face select mode, different view modes, to confirm it
>doesn't crash.
>
>Would be great to have a good script with gui that adds this functionality to
>Blender, btw, so that users can edit in say gimp and see the changes in Blender.
>A button to turn off realtime updates would be nice too.  Just a suggestion! ; )
>Of course some of us can help if needed.
>
>Thanks again,
>
>--
>Willian, wgermano at ig.com.br
>
>
>
>  
>




More information about the Bf-python mailing list