[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/Xsharp Image.cs, 1.3, 1.4 XsharpSupport.c,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/Xsharp Image.cs, 1.3, 1.4 XsharpSupport.c, 1.13, 1.14 |
Date: |
Thu, 02 Oct 2003 01:53:33 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv6097/Xsharp
Modified Files:
Image.cs XsharpSupport.c
Log Message:
Use "DotGNU.Images" to load image files instead of Imlib; modify "XHello"
to display a BMP because JPG support isn't present in "DotGNU.Images" just yet.
Index: XsharpSupport.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/XsharpSupport.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** XsharpSupport.c 1 Oct 2003 23:50:03 -0000 1.13
--- XsharpSupport.c 2 Oct 2003 01:53:30 -0000 1.14
***************
*** 690,700 ****
/*
* Get the write function for an image.
*/
! typedef void (*WriteFunc)(unsigned char *output, unsigned long *input, int
num);
static WriteFunc GetWriteFunc(XImage *image)
{
! /* TODO */
! return 0;
}
--- 690,755 ----
/*
+ * Write RGB data directly to an XImage.
+ */
+ static void Write_Direct(Display *dpy, Colormap colormap, XImage *image,
+ int line, unsigned long
*input, int num)
+ {
+ int column;
+ if(sizeof(unsigned int) == 4)
+ {
+ unsigned int *output = (unsigned int *)
+ (image->data + line * image->bytes_per_line);
+ for(column = 0; column < num; ++column)
+ {
+ *output++ = (unsigned int)(*input++);
+ }
+ }
+ else
+ {
+ unsigned long *output = (unsigned long *)
+ (image->data + line * image->bytes_per_line);
+ for(column = 0; column < num; ++column)
+ {
+ *output++ = *input++;
+ }
+ }
+ }
+
+ /*
+ * Default writing routine, doing per-pixel color allocations.
+ */
+ static void Write_Default(Display *dpy, Colormap colormap, XImage *image,
+ int line, unsigned long
*input, int num)
+ {
+ int column;
+ unsigned long rgb;
+ XColor xcolor;
+ for(column = 0; column < num; ++column)
+ {
+ rgb = *input++;
+ xcolor.pixel = 0;
+ xcolor.red = (unsigned short)((rgb >> 8) & 0xFF00);
+ xcolor.green = (unsigned short)(rgb & 0xFF00);
+ xcolor.blue = (unsigned short)((rgb << 8) & 0xFF00);
+ xcolor.flags = DoRed | DoGreen | DoBlue;
+ xcolor.pad = 0;
+ XAllocColor(dpy, colormap, &xcolor);
+ XPutPixel(image, column, line, xcolor.pixel);
+ }
+ }
+
+ /*
* Get the write function for an image.
*/
! typedef void (*WriteFunc)(Display *dpy, Colormap colormap, XImage *image,
! int len, unsigned long
*input, int num);
static WriteFunc GetWriteFunc(XImage *image)
{
! if(image->depth == 24 && image->red_mask == 0x00FF0000 &&
! image->green_mask == 0x0000FF00 && image->blue_mask == 0x000000FF)
! {
! return Write_Direct;
! }
! return Write_Default;
}
***************
*** 720,723 ****
--- 775,779 ----
Display *dpy = DisplayOfScreen(screen);
Visual *visual = DefaultVisualOfScreen(screen);
+ Colormap colormap = DefaultColormapOfScreen(screen);
unsigned int depth;
int format;
***************
*** 861,866 ****
{
(*readFunc)(data + line * stride, tempLine, width);
! (*writeFunc)(imageData + line * image->bytes_per_line,
! tempLine, width);
}
free(tempLine);
--- 917,921 ----
{
(*readFunc)(data + line * stride, tempLine, width);
! (*writeFunc)(dpy, colormap, image, line, tempLine,
width);
}
free(tempLine);
Index: Image.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Image.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Image.cs 1 Oct 2003 23:50:03 -0000 1.3
--- Image.cs 2 Oct 2003 01:53:30 -0000 1.4
***************
*** 203,206 ****
--- 203,210 ----
/// </exception>
///
+ /// <exception cref="T:System.FormatException">
+ /// <para>The image format is not recognized.</para>
+ /// </exception>
+ ///
/// <exception cref="T:Xsharp.XInvalidOperationException">
/// <para>Raised if <paramref name="filename"/> could not be
***************
*** 228,231 ****
--- 232,239 ----
/// </exception>
///
+ /// <exception cref="T:System.FormatException">
+ /// <para>The image format is not recognized.</para>
+ /// </exception>
+ ///
/// <exception cref="T:Xsharp.XInvalidOperationException">
/// <para>Raised if <paramref name="filename"/> could not be
***************
*** 249,252 ****
--- 257,274 ----
}
this.screen = screen;
+ DotGNU.Images.Image img = new
DotGNU.Images.Image();
+ img.Load(filename);
+ Frame frame = img.GetFrame(0);
+ try
+ {
+ dpy.Lock();
+ pixmapXImage =
ConvertImage.FrameToXImage(screen, frame);
+ maskXImage =
ConvertImage.MaskToXImage(screen, frame);
+ }
+ finally
+ {
+ dpy.Unlock();
+ }
+ #if false
try
{
***************
*** 292,295 ****
--- 314,318 ----
dpy.Unlock();
}
+ #endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/Xsharp Image.cs, 1.3, 1.4 XsharpSupport.c, 1.13, 1.14,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] pnetlib ChangeLog,1.1377,1.1378
- Next by Date:
[Dotgnu-pnet-commits] pnetlib/samples dotgnu-logo.bmp, NONE, 1.1 XHello.cs, 1.5, 1.6
- Previous by thread:
[Dotgnu-pnet-commits] pnetlib ChangeLog,1.1377,1.1378
- Next by thread:
[Dotgnu-pnet-commits] pnetlib/samples dotgnu-logo.bmp, NONE, 1.1 XHello.cs, 1.5, 1.6
- Index(es):