Update of /cvsroot/freevo/freevo/lib/pyimlib2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15436
Modified Files:
Imlib2.py image.c
Log Message:
fix file saving format and add function to turn alpha on/off
Index: image.c
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/pyimlib2/image.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** image.c 7 Sep 2004 18:59:43 -0000 1.5
--- image.c 21 Sep 2004 18:05:09 -0000 1.6
***************
*** 341,344 ****
--- 341,358 ----
}
+
+ PyObject *Image_PyObject__set_alpha(PyObject *self, PyObject *args)
+ {
+ int alpha = 0;
+
+ if (!PyArg_ParseTuple(args, "i", &alpha))
+ return NULL;
+ imlib_context_set_image(((Image_PyObject *)self)->image);
+ imlib_image_set_has_alpha(alpha);
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+
PyObject *Image_PyObject__copy_rect(PyObject *self, PyObject *args)
{
***************
*** 438,452 ****
PyObject *Image_PyObject__save(PyObject *self, PyObject *args)
{
! unsigned char *filename;
!
! if (!PyArg_ParseTuple(args, "s", &filename))
return NULL;
imlib_context_set_image(((Image_PyObject *)self)->image);
// TODO: call imlib_save_image_with_error_return
imlib_save_image(filename);
Py_INCREF(Py_None);
return Py_None;
}
PyMethodDef Image_PyObject_methods[] = {
{ "draw_rectangle", Image_PyObject__draw_rectangle, METH_VARARGS },
--- 452,472 ----
PyObject *Image_PyObject__save(PyObject *self, PyObject *args)
{
! unsigned char *filename, *ext;
!
! if (!PyArg_ParseTuple(args, "ss", &filename, &ext))
return NULL;
imlib_context_set_image(((Image_PyObject *)self)->image);
// TODO: call imlib_save_image_with_error_return
+
+ /* set the image format to be the format of the extension of our last */
+ /* argument - i.e. .png = png, .tif = tiff etc. */
+ imlib_image_set_format(ext);
imlib_save_image(filename);
Py_INCREF(Py_None);
return Py_None;
}
+
+
PyMethodDef Image_PyObject_methods[] = {
{ "draw_rectangle", Image_PyObject__draw_rectangle, METH_VARARGS },
***************
*** 462,465 ****
--- 482,486 ----
{ "flip", Image_PyObject__flip, METH_VARARGS },
{ "blend", Image_PyObject__blend, METH_VARARGS },
+ { "set_alpha", Image_PyObject__set_alpha, METH_VARARGS },
{ "move_to_shmem", Image_PyObject__move_to_shmem, METH_VARARGS },
{ "get_bytes", Image_PyObject__get_bytes, METH_VARARGS },
Index: Imlib2.py
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/pyimlib2/Imlib2.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Imlib2.py 7 Sep 2004 19:00:11 -0000 1.7
--- Imlib2.py 21 Sep 2004 18:05:08 -0000 1.8
***************
*** 425,428 ****
--- 425,444 ----
return self._image.move_to_shmem(format, id)
+
+ def set_alpha(self, has_alpha):
+ """
+ Enable / disable the alpha layer.
+
+ Arguments:
+ has_alpha: if True, the alpha layer will be enabled, if
+ False disabled
+ Returns: None
+ """
+ if has_alpha:
+ self._image.set_alpha(1)
+ else:
+ self._image.set_alpha(0)
+
+
def save(self, filename, format = None):
"""
***************
*** 435,439 ****
Returns: None.
"""
! return self._image.save(filename)
def to_sdl_surface(self, sdl_surface):
--- 451,458 ----
Returns: None.
"""
! if not format:
! format = os.path.splitext(filename)[1][1:]
! return self._image.save(filename, format)
!
def to_sdl_surface(self, sdl_surface):
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog