Need some help.

Programming Reality Factory and Genesis3D.
Post Reply
User avatar
Destron
Posts: 520
Joined: Thu Apr 19, 2007 7:30 pm

Need some help.

Post by Destron » Thu Jan 31, 2008 5:40 pm

Hey, I want to create a (somewhat) simple procedural texture editor. I don't know a whole lot about programming (just how to create a "hello world" console app :roll:), but I know I can't just jump and and know how to do this.
That said, what's a good language to learn for this? I mostly want to combine existing images, rather than add in, say, a perlin noise or sine generator, although I may eventually do that.
I was thinking something like Visual Basic (although this is shunned by a lot of programmers).
What do you guys think?

p.s. - some features I would like to include:
- BMP Export
- Image Blending Modes (Add, Subtract, Multiply, etc)
- Misc "simple" filters (e.g. colorize, blur, etc)

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Need some help.

Post by Allanon » Thu Jan 31, 2008 8:14 pm

Might try using the Python Programming Language. It is very easy to use and it has a lot of 3rd party libraries such as the Python Imaging Library which makes it very easy to manipulate images.

Here is an example of how easy it is, after loading Python and the Python Imaging Library just open up any word processor and enter the following code:

Code: Select all

# load libraries
from PIL import Image
from PIL import ImageChops

# load images
im1 = Image.open("test1.jpg")
im2 = Image.open("test2.jpg")

# merge images
im3 = ImageChops.multiply(im1, im2)

# show the image 
im3.show()

# save the image
im3.save("test3.jpg")
Save the code as test.py. Make sure you have 2 JPEG images named test1.jpg and test2.jpg in the same folder as test.py. Then run the program by double clicking on test.py. The program will load test1.jpg and test2.jpg then merge them in to a new image. Then the program will display the new image using Windows default image viewer. Once the image viewer is closed the program will then save the image to the name test3.jpg.

If you read the documentation to the Python Imaging Library you will see how easy it is to do all kinds of other image manipulation tricks. I just started using python a few days ago because someone ported the Tivo HME SDK over to it and I have found Python to be easy and a joy to work with.

User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Re: Need some help.

Post by jonas » Thu Jan 31, 2008 8:31 pm

Nice :D I love Python. I didn't think about it being used for image manipulation... That could be fairly simple. I haven't played with it a lot, but is it fairly simple to create win32 applications with python alone, or do you still need to create a c++ program and call the python binary or can you do it just straight python?
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack

User avatar
Destron
Posts: 520
Joined: Thu Apr 19, 2007 7:30 pm

Re: Need some help.

Post by Destron » Thu Jan 31, 2008 9:06 pm

I forgot about Python!

Thanks a lot Allanon, I'll check those out. :)
That could be fairly simple. I haven't played with it a lot, but is it fairly simple to create win32 applications with python alone, or do you still need to create a c++ program and call the python binary or can you do it just straight python?
I'm not sure... I guess I'll have to look into that.


EDIT: Whoa, this stuff really works! I'll have figure out how to implement it with a GUI and stuff.

Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

Re: Need some help.

Post by Allanon » Thu Jan 31, 2008 10:38 pm

I never did GUI programming with Python until now. I picked EasyGUI from the list of many Python GUI frameworks mostly because of the name. After a little reading of the documentation I was able to rewrite the above sample with a GUI and a little more functionality. This sample works with almost any kind of popular image format and you can save to any popular format just by using the correct file extension when saving.

Code: Select all

# load libraries
from PIL import Image
from PIL import ImageChops
from easygui import *

# load images
file1 = fileopenbox("choose image 1", "Choose Image", "*.*")
file2 = fileopenbox("choose image 2", "Choose Image", "*.*")

im1 = Image.open(file1)
im2 = Image.open(file2)

# blend the images
choice = choicebox("How do you want to blend the images", "Blend Images", ["Multiple","Difference","Add","Subtract" ,"Screen","Darker","Lighter"])

if choice == "Multiply":
    im3 =ImageChops.multiply(im1, im2)

if choice == "Differance":
    im3 =ImageChops.difference(im1, im2)

if choice == "Add":
    im3 =ImageChops.add(im1, im2)

if choice == "Subtract":
    im3 =ImageChops.subtract(im1, im2)

if choice == "Screen":
    im3 = ImageChops.screen(im1, im2)

if choice == "Darker":
    im3 =ImageChops.darker(im1, im2)

if choice == "Lighter":
    im3 =ImageChops.lighter(im1, im2)

# show the image 
im3.show()

# save the image
file3 = filesavebox("Save the image","Save Image", "*.*")

im3.save(file3)
See how easy it is! :)

User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Re: Need some help.

Post by jonas » Thu Jan 31, 2008 10:50 pm

wow...Going to have to give python the tripple thumbs up! Very nice...I can see why andycr mentioned using this for rf2. :D
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack

User avatar
Destron
Posts: 520
Joined: Thu Apr 19, 2007 7:30 pm

Re: Need some help.

Post by Destron » Fri Feb 01, 2008 1:47 am

Thanks, Allanon, I really appreciate it... this'll help me out a lot! :)

User avatar
zany_001
Posts: 1047
Joined: Fri Mar 02, 2007 8:36 am
Location: Aotearoa

Re: Need some help.

Post by zany_001 » Fri Feb 01, 2008 1:57 am

you could try Java 2 too, its got quite good imagemaking stuff with it.
Once I was sad, and I stopped being sad and was awesome instead.
True story.

Post Reply