473,748 Members | 6,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fast 2D Raster Rendering with GUI

Hi All. I've been formulating in my head a simple image editor. I
actually started prototyping is some time ago in Java, but am liking
Python more and more. My editor will be nowhere near the level of Gimp/
Photoshop, but I do need fast pixel level control and display. For
instance, that means no automatic anti-aliasing and that I will be
implementing my own line drawing algorithms.

I've got the high level architectual aspects of my program down, but
am stuck on what graphics API to use. I want a canvas area of
adjustable size which users can draw on with as little lag as
possible. The canvas area will be composed of layers (i.e. I require
an alpha channel) and I need to be able to zoom in and out of it (zoom
levels will be at fixed intervals, so this can be simulated if need
be.)

I started looking at PyGame but realize that I need to integrate a GUI
into the whole thing (or integrate the image into the GUI rather) and
I didn't see a straightforward way to do that. Of course, I don't even
know if PyGame is the right API for the job anyways :P

Any thoughts or ideas that could help me get started? Thanks!
Mar 18 '08 #1
7 3687
On Mar 18, 4:36 am, dave <man...@gmail.c omwrote:
Hi All. I've been formulating in my head a simple image editor. I
actually started prototyping is some time ago in Java, but am liking
Python more and more. My editor will be nowhere near the level of Gimp/
Photoshop, but I do need fast pixel level control and display. For
instance, that means no automatic anti-aliasing and that I will be
implementing my own line drawing algorithms.

I've got the high level architectual aspects of my program down, but
am stuck on what graphics API to use. I want a canvas area of
adjustable size which users can draw on with as little lag as
possible. The canvas area will be composed of layers (i.e. I require
an alpha channel) and I need to be able to zoom in and out of it (zoom
levels will be at fixed intervals, so this can be simulated if need
be.)

I started looking at PyGame but realize that I need to integrate a GUI
into the whole thing (or integrate the image into the GUI rather) and
I didn't see a straightforward way to do that. Of course, I don't even
know if PyGame is the right API for the job anyways :P

Any thoughts or ideas that could help me get started? Thanks!
Look at the PIL source code for reference and implement your own C
extensions for drawing and image manipulation. Or write your app on
top of PIL. Any GUI toolkit will work if you find the low-level access
to their image memory buffers. PyGame is for multimedia applications,
you probably need Tkinter, Qt, wx or GTK.

And as long as you need such low-level things as custom drawing and
anti-aliasing your API is plain old C malloc's, free's and raw memory
addresses.

--
Ivan
Mar 18 '08 #2
Hello Dave,
Hi All. I've been formulating in my head a simple image editor. I
actually started prototyping is some time ago in Java, but am liking
Python more and more. My editor will be nowhere near the level of Gimp/
Photoshop, but I do need fast pixel level control and display. For
instance, that means no automatic anti-aliasing and that I will be
implementing my own line drawing algorithms.

I've got the high level architectual aspects of my program down, but
am stuck on what graphics API to use. I want a canvas area of
adjustable size which users can draw on with as little lag as
possible. The canvas area will be composed of layers (i.e. I require
an alpha channel) and I need to be able to zoom in and out of it (zoom
levels will be at fixed intervals, so this can be simulated if need
be.)

I started looking at PyGame but realize that I need to integrate a GUI
into the whole thing (or integrate the image *into the GUI rather) and
I didn't see a straightforward way to do that. Of course, I don't even
know if PyGame is the right API for the job anyways :P

Any thoughts or ideas that could help me get started? Thanks!
Apart from PIL, some other options are:
1. Most GUI frameworks (wxPython, PyQT, ...) give you a canvas object
you can draw on
2. A bit of an overkill, but you can use PyOpenGL
3. ImageMagick bindings? (http://www.imagemagick.org/script/api.php)

HTH,
--
Miki <mi*********@gm ail.com>
http://pythonwise.blogspot.com
Mar 18 '08 #3
Chris Mellon <ar*****@gmail. comwrote:
>OpenGL is totally unsuitable if the goal is to implement your own
pixel-level raster drawing.
Unfornately, any solution involving Python is likely to be unsuitable
if your goal is to set individual pixels one-by-one, and GDI would be no
better than OpenGL here. The overhead of calling some sort of putpixel()
function over and over will domininate everything else.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.u waterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
Mar 18 '08 #4
First I want to say thank you all for your timely replies. This is all
good food for thought. I've been programming more many years, but fast
graphics rendering is new territory for me.

I'm hoping to fine something like a buffer_blit, where I can set all
the pixels to change using basic operators, blit them all at once to a
pixel buffer, then swap the visible buffer. Ideally it will only
change the region of the pixel buffer that needs changing.

Because I want layers, I would like to take advantage wherever
possible of the available hardware features. I.E. ideally I am hoping
that the layers can be textures in memory that get composited in
hardware onto the screen. Maybe this is wishful thinking though?

I'm also thinking that maybe I can reduce the number of active layers
from N down to 3 - the active layer, the layers below it, and the
layers above it. Obviously only the active layer needs any sort of
sprite-like animations and it on this layer than response time is most
important. Having to layer the top layers ontop of it may also play a
factor but, as I suggested, I can merge them all together in one time
and then use the merged result to layer on top of the active layer.

I'm a little nervous about going the C/C++ route. It's been a few
years since I used them, I'm new to Python, and jumping into coding
Python extensions with C/C++ is not particularly palatable (though
I'll do it if I have to.)
Any GUI toolkit will work if you find the low-level access
to their image memory buffers.
That's another new step for me. Any ideas where to start? Thanks!
Mar 18 '08 #5
On Mar 19, 2:33 am, dave <man...@gmail.c omwrote:
First I want to say thank you all for your timely replies. This is all
good food for thought. I've been programming more many years, but fast
graphics rendering is new territory for me.

I'm hoping to fine something like a buffer_blit, where I can set all
the pixels to change using basic operators, blit them all at once to a
pixel buffer, then swap the visible buffer. Ideally it will only
change the region of the pixel buffer that needs changing.

Because I want layers, I would like to take advantage wherever
possible of the available hardware features. I.E. ideally I am hoping
that the layers can be textures in memory that get composited in
hardware onto the screen. Maybe this is wishful thinking though?

I'm also thinking that maybe I can reduce the number of active layers
from N down to 3 - the active layer, the layers below it, and the
layers above it. Obviously only the active layer needs any sort of
sprite-like animations and it on this layer than response time is most
important. Having to layer the top layers ontop of it may also play a
factor but, as I suggested, I can merge them all together in one time
and then use the merged result to layer on top of the active layer.

I'm a little nervous about going the C/C++ route. It's been a few
years since I used them, I'm new to Python, and jumping into coding
Python extensions with C/C++ is not particularly palatable (though
I'll do it if I have to.)
Any GUI toolkit will work if you find the low-level access
to their image memory buffers.

That's another new step for me. Any ideas where to start? Thanks!
Some reading on fast 2d graphics:
chapters 35-42 from
http://www.byte.com/abrash/

and a lot of great stuff here:
http://tog.acm.org/GraphicsGems/
Mar 18 '08 #6
That's another new step for me. Any ideas where to start?

http://docs.python.org/ext/simpleExample.html

And look into the source of existing extensions. PIL and PyCairo are
the best in your situation.

Mar 18 '08 #7
On Mar 18, 6:51 pm, Ivan Illarionov <ivan.illario.. .@gmail.comwrot e:
That's another new step for me. Any ideas where to start?

http://docs.python.org/ext/simpleExample.html

And look into the source of existing extensions. PIL and PyCairo are
the best in your situation.
You shouldn't be afraid of doing raster graphics in Python; you'll
just need to be familiar with Numpy. You can easily compose layers,
mask out operations to only happen on one channel, etc., and code it
all up in Python while getting C-level speed. The gotcha, if you use
PIL, is that you're going to have to use tostring() and fromstring()
to get the array data back and forth between numpy and PIL. An
alternative is to use openGL, as others have suggested, and blit into
a texture. If you use pyglet, for instance, you can use Andrew
Straw's pygarrayimage module to convert a numpy array directly into a
texture.

I wouldn't recommend Cairo for doing pixel-level ops, since it is a
vector graphics library.
-Peter
Mar 19 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3672
by: Tole | last post by:
hi all, i've got a selcetbox (multiple) which is filled by javascript. only problem is that i have aprox 1000 options to add to that select, and that adding lasts for 5-6 seconds. Even select.length = 0 (on filled element) lasts for few seconds. ok. i have large amount of data to preload, and i also do some operations on that data, but it's all very fast. so i thought it must be some IE rendering issue, and i tried to set...
7
9542
by: Maxim Shemanarev | last post by:
I'd like to announce my project called Anti-Grain Geometry. http://www.antigrain.com Anti-Grain Geometry (AGG) is an Open Source, free of charge graphic library, written in industrially standard C++. The terms and conditions of use are very simple and described on the License page. AGG doesn't depend on any graphic API or technology. Basically, you can think of AGG as of a rendering engine that produces pixel images in memory from
1
4603
by: John Tempest | last post by:
Please help. I got no response to my previous query "?Using raster fonts as graphics in dotNet?" posted on 7th July. The principal question remains: How can I (if I can at all) select a raster font (say with extension .fon) to associate with a form and use it to draw text on the form? The problem seems to be that names of raster fonts aren't recognised in the Font constructor which requires fonts to be members of a font family (ie in...
4
4458
by: Nick K. | last post by:
Is there any native ,Net assemblies or open C# source code that can perform vector to raster conversion?
7
5177
by: Dennis Benzinger | last post by:
Hi! Does anybody know of a SVG rendering library for Python? Bye, Dennis
2
3263
by: Spotnick | last post by:
I have no idea why, but since I'm trying to recreate my website using ASP.NET 2.0 I've encountered so many performance issues that I'm about to give up and continue using v1.1 Seriously, how can a page that is not that complicated be so long to render locally, it's amazing. This is the trace info: aspx.page Begin PreInit
6
2376
dmjpro
by: dmjpro | last post by:
frnds .. i understand that why AJAX is introduced in web-technology and also i am very interested in AJAX..... but one question stil knocking me ... why AJAX is fast than normal request??? about this what i have .... i think both of these use same protocol HTTP , inspite of that the why AJAX is very fast... one reason may be there ... rendering the page needs more time ..... m i right .. this is my funda on this context ....
4
1812
by: alarock | last post by:
hi, I have performed some drawing using Vector image,DrawRectangle etc... and then i converted to raster Image(bitmap) i found in the zoomed raster image(bitmap) the outer boundary of the raster image(bitmap) is blurry. i used Interpolation mode,smoothing mode,,and tried a lot ..... i cant able to solve this problem in C#...Please help me to solve this...... Regards, alarock(algates)
7
1767
by: VC | last post by:
Hi I'm working on a web site with hard programming in Javascript. ?This web based application is intended to be used by bank workers who types very fast. The problem is: sometimes they type so fast that when they hit the ENTER key, the javascript related with this key is executed, but the <input TEXT...associated, that wasnt rendered yet. So we face the 'Object expected' error.
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.