Exemple #1
0
        /// <summary>
        /// updates the given Pixbuf object from the bitmap array
        /// </summary>
        /// updates the given image object from the bitmap array
        public static Gdk.Pixbuf setBitmap(byte[] bmp, Gdk.Pixbuf pixbuffer)
        {
            if (pixbuffer != null)
            {
                Gdk.Pixdata pd = new Gdk.Pixdata();

                // extract the raw data in uncompressed format
                pd.FromPixbuf(pixbuffer, false);
                byte[] pixel = pd.Serialize();

                // set the pixel values
                for (int i = 0; i < bmp.Length; i++)
                {
                    pixel[pixdata_header + i] = (byte)bmp[i];
                }

                pd.Deserialize((uint)pixel.Length, pixel);

                // return the pixel data as a Pixbuf object in compressed format
                return(Gdk.Pixbuf.FromPixdata(pd, true));
            }
            else
            {
                EventLog.AddError("GtkBitmap/getBitmap/pixbuffer has not been initialised");
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// updates the given Pixbuf object from the bitmap array
        /// </summary>
        /// updates the given image object from the bitmap array
        public static Gdk.Pixbuf setBitmapOld(byte[] bmp, Gdk.Pixbuf pixbuffer)
        {
            if (pixbuffer != null)
            {
                Gdk.Pixdata pd = new Gdk.Pixdata();

                // extract the raw data in uncompressed format
                pd.FromPixbuf(pixbuffer, false);

                // TODO call to serialize causes memory leak

                byte[] pixel = pd.Serialize();

                // set the pixel values, converting BGR to RGB
                for (int i = 0; i < bmp.Length; i += 3)
                {
                    for (int col = 0; col < 3; col++)
                    {
                        pixel[pixdata_header + i + col] = bmp[i + 2 - col];
                    }
                }

                pd.Deserialize((uint)pixel.Length, pixel);

                Gdk.Pixbuf result = Gdk.Pixbuf.FromPixdata(pd, false);

                // return the pixel data as a Pixbuf object in compressed format
                return(result);
            }
            else
            {
                Console.WriteLine("GtkBitmap/getBitmap/pixbuffer has not been initialised");
                return(null);
            }
        }
Exemple #3
0
        public virtual byte [] GetAlbumCover()
        {
            if (player.PlayingSong == null ||
                player.PlayingSong.CoverImage == null)
            {
                return(new byte[0]);
            }

            Gdk.Pixdata pixdata = new Gdk.Pixdata();
            pixdata.FromPixbuf(player.PlayingSong.CoverImage, true);

            return(pixdata.Serialize());
        }
Exemple #4
0
        /// <summary>
        /// returns the bitmap data from a Pixbuf object
        /// </summary>
        public static void getBitmap(Gdk.Pixbuf pixbuffer, byte[] bmp)
        {
            if (pixbuffer != null)
            {
                if (bmp != null)
                {
                    Gdk.Pixdata pd = new Gdk.Pixdata();

                    pd.FromPixbuf(pixbuffer, false);
                    byte[] pixel = pd.Serialize();

                    if (pd.Rowstride != pixbuffer.Width * 3)
                    {
                        // uneven stride length
                        long real_length = pd.Rowstride * pixbuffer.Height;
                        long n           = 0;
                        long w           = pixbuffer.Width * 3;
                        for (int y = 0; y < pixbuffer.Height; y++)
                        {
                            long n1 = (y * pixbuffer.Width) * 3;
                            for (int x = 0; x < pd.Rowstride; x++)
                            {
                                if (x < w)
                                {
                                    bmp[n1] = pixel[n];
                                }
                                n++;
                                n1++;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < bmp.Length; i++)
                        {
                            bmp[i] = pixel[pixdata_header + i];
                        }
                    }

                    pd.Deserialize((uint)pixel.Length, pixel);
                }
                else
                {
                    EventLog.AddError("GtkBitmap/getBitmap/bmp not defined");
                }
            }
            else
            {
                EventLog.AddError("GtkBitmap/getBitmap/pixbuffer has not been initialised");
            }
        }
Exemple #5
0
		/// <summary>
		/// returns the bitmap data from a Pixbuf object
		/// </summary>
		public static void getBitmap(Gdk.Pixbuf pixbuffer, byte[] bmp)
		{
		    if (pixbuffer != null)
		    {
		        if (bmp != null)
		        {
					Gdk.Pixdata pd = new Gdk.Pixdata();
																	
					pd.FromPixbuf(pixbuffer, false);
					byte[] pixel = pd.Serialize();
					
					if (pd.Rowstride != pixbuffer.Width*3)
					{
					    // uneven stride length
					    //long real_length = pd.Rowstride * pixbuffer.Height;
					    long n = 0;
					    long w = pixbuffer.Width*3;
					    for (int y = 0; y < pixbuffer.Height; y++)
					    {
					        long n1 = (y*pixbuffer.Width)*3;
					        for (int x = 0; x < pd.Rowstride; x++)
					        {
					            if (x < w) bmp[n1] = pixel[n];
					            n++;
					            n1++;
					        }
					    }
					}
					else
					{
			            for (int i = 0; i < bmp.Length; i++)
		                    bmp[i] = pixel[pixdata_header + i];
		            }
					
					pd.Deserialize((uint)pixel.Length, pixel);
				}
				else Console.WriteLine("GtkBitmap/getBitmap/bmp not defined");
		    }
		    else Console.WriteLine("GtkBitmap/getBitmap/pixbuffer has not been initialised");
		}
Exemple #6
0
		/// <summary>
	    /// updates the given Pixbuf object from the bitmap array
	    /// </summary>
		/// updates the given image object from the bitmap array
		public static Gdk.Pixbuf setBitmapOld(byte[] bmp, Gdk.Pixbuf pixbuffer)
		{
		    if (pixbuffer != null)
		    {
		        Gdk.Pixdata pd = new Gdk.Pixdata();
				
				// extract the raw data in uncompressed format
			    pd.FromPixbuf(pixbuffer, false);
			    
			    // TODO call to serialize causes memory leak
			    
				byte[] pixel = pd.Serialize();				
				
				// set the pixel values, converting BGR to RGB
				for (int i = 0; i < bmp.Length; i += 3)
				{
				    for (int col = 0; col < 3; col++)
				        pixel[pixdata_header + i + col] = bmp[i + 2 - col];
				}
					
				pd.Deserialize((uint)pixel.Length, pixel);		

				Gdk.Pixbuf result = Gdk.Pixbuf.FromPixdata(pd, false); 
				
				// return the pixel data as a Pixbuf object in compressed format
				return(result);
		    }
		    else
		    {
		        Console.WriteLine("GtkBitmap/getBitmap/pixbuffer has not been initialised");
		        return(null);
		    }
		}
Exemple #7
0
 static extern IntPtr gdk_pixdata_serialize(ref Gdk.Pixdata raw, out uint len);
Exemple #8
0
		/// <summary>
	    /// updates the given Pixbuf object from the bitmap array
	    /// </summary>
		/// updates the given image object from the bitmap array
		public static Gdk.Pixbuf setBitmap(byte[] bmp, Gdk.Pixbuf pixbuffer)
		{
		    if (pixbuffer != null)
		    {
				Gdk.Pixdata pd = new Gdk.Pixdata();
					
				// extract the raw data in uncompressed format
			    pd.FromPixbuf(pixbuffer, false);
				byte[] pixel = pd.Serialize();
				
				// set the pixel values
				for (int i = 0; i < bmp.Length; i++) 
				    pixel[pixdata_header + i] = (byte)bmp[i];				    
					
				pd.Deserialize((uint)pixel.Length, pixel);		
				
				// return the pixel data as a Pixbuf object in compressed format
				return(Gdk.Pixbuf.FromPixdata(pd, true));
		    }
		    else
		    {
		        EventLog.AddError("GtkBitmap/getBitmap/pixbuffer has not been initialised");
		        return(null);
		    }
		}