Author: jwilcox
Date: 2006-09-18 09:50:56 -0400 (Mon, 18 Sep 2006)
New Revision: 65578
Modified:
trunk/ipod-sharp/ChangeLog
trunk/ipod-sharp/configure.ac
trunk/ipod-sharp/src/Device.cs
trunk/ipod-sharp/src/Thumbnail.cs
trunk/ipod-sharp/tools/PhotoAdder.cs
trunk/ipod-sharp/ui/ArtworkHelpers.cs
Log:
2006-09-18 James Willcox <[EMAIL PROTECTED]>
* configure.ac: bump to 0.6.2
* Device.cs: use new libipoddevice artwork format API, and change
ours to be similar. Also add new properties ManufacturerId,
ProductionYear, ProductionWeek, and ProductionIndex.
Modified: trunk/ipod-sharp/ChangeLog
===================================================================
--- trunk/ipod-sharp/ChangeLog 2006-09-18 13:38:42 UTC (rev 65577)
+++ trunk/ipod-sharp/ChangeLog 2006-09-18 13:50:56 UTC (rev 65578)
@@ -1,3 +1,10 @@
+2006-09-18 James Willcox <[EMAIL PROTECTED]>
+
+ * configure.ac: bump to 0.6.2
+ * Device.cs: use new libipoddevice artwork format API, and change
+ ours to be similar. Also add new properties ManufacturerId,
+ ProductionYear, ProductionWeek, and ProductionIndex.
+
2006-09-12 James Willcox <[EMAIL PROTECTED]>
* configure.ac: bump version to 0.6.1
Modified: trunk/ipod-sharp/configure.ac
===================================================================
--- trunk/ipod-sharp/configure.ac 2006-09-18 13:38:42 UTC (rev 65577)
+++ trunk/ipod-sharp/configure.ac 2006-09-18 13:50:56 UTC (rev 65578)
@@ -3,7 +3,7 @@
MAJOR_VERSION=0
MINOR_VERSION=6
-MICRO_VERSION=1
+MICRO_VERSION=2
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
AM_INIT_AUTOMAKE(ipod-sharp, $VERSION)
@@ -18,7 +18,7 @@
AM_MAINTAINER_MODE
-PKG_CHECK_MODULES(IPODDEVICE, ipoddevice >= 0.4.6 gtk-sharp-2.0)
+PKG_CHECK_MODULES(IPODDEVICE, ipoddevice >= 0.5.0 gtk-sharp-2.0)
dnl Mono
AC_PATH_PROG(MONO, mono)
Modified: trunk/ipod-sharp/src/Device.cs
===================================================================
--- trunk/ipod-sharp/src/Device.cs 2006-09-18 13:38:42 UTC (rev 65577)
+++ trunk/ipod-sharp/src/Device.cs 2006-09-18 13:50:56 UTC (rev 65578)
@@ -14,34 +14,31 @@
Busy
};
- public enum ArtworkType : int {
- CoverSmall,
- CoverLarge,
- PhotoSmall,
- PhotoLarge,
- PhotoFullScreen,
- PhotoTvScreen
+ public enum ArtworkUsage : int {
+ Unknown = -1,
+ Photo,
+ Cover
}
- public enum ImageType : int {
+ public enum PixelFormat : int {
+ Unknown = -1,
Rgb565,
- Rgb56590,
Rgb565BE,
- Rgb565BE90,
IYUV
}
public class ArtworkFormat {
- private ArtworkType artType;
+ private ArtworkUsage usage;
private short width;
private short height;
private short correlationId;
private int size;
- private ImageType imgType;
+ private PixelFormat pformat;
+ private short rotation;
- public ArtworkType ArtworkType {
- get { return artType; }
+ public ArtworkUsage Usage {
+ get { return usage; }
}
public short Width {
@@ -56,22 +53,27 @@
get { return size; }
}
- public ImageType ImageType {
- get { return imgType; }
+ public PixelFormat PixelFormat {
+ get { return pformat; }
}
+ public short Rotation {
+ get { return rotation; }
+ }
+
internal short CorrelationId {
get { return correlationId; }
}
- internal ArtworkFormat (ArtworkType artType, short width, short
height, short correlationId,
- int size, ImageType imgType) {
- this.artType = artType;
+ internal ArtworkFormat (ArtworkUsage usage, short width, short height,
short correlationId,
+ int size, PixelFormat pformat, short rotation)
{
+ this.usage = usage;
this.width = width;
this.height = height;
this.correlationId = correlationId;
this.size = size;
- this.imgType = imgType;
+ this.pformat = pformat;
+ this.rotation = rotation;
}
}
@@ -253,8 +255,32 @@
}
}
- public IList<ArtworkFormat> ArtworkFormats {
+ public string ManufacturerId {
get {
+ return (string) GetProperty ("manufacturer-id").Val;
+ }
+ }
+
+ public uint ProductionYear {
+ get {
+ return (uint) GetProperty ("production-year").Val;
+ }
+ }
+
+ public uint ProductionWeek {
+ get {
+ return (uint) GetProperty ("production-week").Val;
+ }
+ }
+
+ public uint ProductionIndex {
+ get {
+ return (uint) GetProperty ("production-index").Val;
+ }
+ }
+
+ public ReadOnlyCollection<ArtworkFormat> ArtworkFormats {
+ get {
return new ReadOnlyCollection<ArtworkFormat> (new
List<ArtworkFormat> (formats.Values));
}
}
@@ -320,10 +346,10 @@
int offset = 0;
while (true) {
- int artType = Marshal.ReadInt32 (array, offset);
+ int usage = Marshal.ReadInt32 (array, offset);
offset += 4;
- if (artType == -1)
+ if (usage == -1)
break;
short width = Marshal.ReadInt16 (array, offset);
@@ -338,27 +364,32 @@
int size = Marshal.ReadInt32 (array, offset);
offset += 4;
- int imgType = Marshal.ReadInt32 (array, offset);
+ int pformat = Marshal.ReadInt32 (array, offset);
offset += 4;
+
+ short rotation = Marshal.ReadInt16 (array, offset);
+ offset += 4;
- formats[correlationId] = new ArtworkFormat ((ArtworkType)
artType, width, height, correlationId,
- size, (ImageType)
imgType);
+ formats[correlationId] = new ArtworkFormat ((ArtworkUsage)
usage, width, height, correlationId,
+ size,
(PixelFormat) pformat, rotation);
}
}
public Device (string mountOrDevice) : this (ipod_device_new
(mountOrDevice)) {
}
- public ArtworkFormat LookupFormat (ArtworkType type) {
+ public ReadOnlyCollection<ArtworkFormat> LookupArtworkFormats
(ArtworkUsage usage) {
+ List<ArtworkFormat> list = new List<ArtworkFormat> ();
foreach (ArtworkFormat format in formats.Values) {
- if (format.ArtworkType == type)
- return format;
+ if (format.Usage == usage) {
+ list.Add (format);
+ }
}
- return null;
+ return new ReadOnlyCollection<ArtworkFormat> (list);
}
- internal ArtworkFormat LookupFormat (int correlationId) {
+ internal ArtworkFormat LookupArtworkFormat (int correlationId) {
return formats[correlationId];
}
Modified: trunk/ipod-sharp/src/Thumbnail.cs
===================================================================
--- trunk/ipod-sharp/src/Thumbnail.cs 2006-09-18 13:38:42 UTC (rev 65577)
+++ trunk/ipod-sharp/src/Thumbnail.cs 2006-09-18 13:50:56 UTC (rev 65578)
@@ -70,7 +70,7 @@
this.record = record;
if (record.CorrelationId > 0) {
- Format = photo.PhotoDatabase.Device.LookupFormat
(record.CorrelationId);
+ Format = photo.PhotoDatabase.Device.LookupArtworkFormat
(record.CorrelationId);
}
}
Modified: trunk/ipod-sharp/tools/PhotoAdder.cs
===================================================================
--- trunk/ipod-sharp/tools/PhotoAdder.cs 2006-09-18 13:38:42 UTC (rev
65577)
+++ trunk/ipod-sharp/tools/PhotoAdder.cs 2006-09-18 13:50:56 UTC (rev
65578)
@@ -10,11 +10,7 @@
private static string directory;
private static void AddThumbnails (Device device, Photo photo, Gdk.Pixbuf
pixbuf) {
- foreach (ArtworkFormat format in device.ArtworkFormats) {
- if (format.ArtworkType != ArtworkType.PhotoSmall &&
format.ArtworkType != ArtworkType.PhotoLarge &&
- format.ArtworkType != ArtworkType.PhotoFullScreen &&
format.ArtworkType != ArtworkType.PhotoTvScreen)
- continue;
-
+ foreach (ArtworkFormat format in device.LookupArtworkFormats
(ArtworkUsage.Photo)) {
byte[] bytes;
short padX, padY;
Modified: trunk/ipod-sharp/ui/ArtworkHelpers.cs
===================================================================
--- trunk/ipod-sharp/ui/ArtworkHelpers.cs 2006-09-18 13:38:42 UTC (rev
65577)
+++ trunk/ipod-sharp/ui/ArtworkHelpers.cs 2006-09-18 13:50:56 UTC (rev
65578)
@@ -223,32 +223,26 @@
Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8,
format.Width, format.Height);
Gdk.Pixbuf rotated = null;
- switch (format.ImageType) {
- case ImageType.Rgb565:
+ switch (format.PixelFormat) {
+ case PixelFormat.Rgb565:
UnpackRgb565 (data, pixbuf, false);
break;
- case ImageType.Rgb56590:
- UnpackRgb565 (data, pixbuf, false);
- rotated = pixbuf.RotateSimple (Gdk.PixbufRotation.Clockwise);
- pixbuf.Dispose ();
- pixbuf = rotated;
- break;
- case ImageType.Rgb565BE:
+ case PixelFormat.Rgb565BE:
UnpackRgb565 (data, pixbuf, true);
break;
- case ImageType.Rgb565BE90:
- UnpackRgb565 (data, pixbuf, true);
- rotated = pixbuf.RotateSimple (Gdk.PixbufRotation.Clockwise);
- pixbuf.Dispose ();
- pixbuf = rotated;
- break;
- case ImageType.IYUV:
+ case PixelFormat.IYUV:
UnpackIYUV (data, pixbuf);
break;
default:
- throw new ApplicationException ("Unknown image type: " +
format.ImageType);
+ throw new ApplicationException ("Unknown pixel format: " +
format.PixelFormat);
}
+ if (format.Rotation > 0) {
+ rotated = Rotate (pixbuf, format.Rotation);
+ pixbuf.Dispose ();
+ pixbuf = rotated;
+ }
+
return pixbuf;
}
@@ -257,6 +251,18 @@
return ToBytes (format, pixbuf, out a, out b);
}
+ private static Gdk.Pixbuf Rotate (Gdk.Pixbuf pixbuf, int angle) {
+ Gdk.Pixbuf rotated = pixbuf;
+
+ for (int i = 0; i < (angle / 90); i++) {
+ pixbuf = rotated.RotateSimple
(Gdk.PixbufRotation.Counterclockwise);
+ rotated.Dispose ();
+ rotated = pixbuf;
+ }
+
+ return rotated;
+ }
+
public static byte[] ToBytes (ArtworkFormat format, Gdk.Pixbuf pixbuf,
out short horizontalPadding,
out short verticalPadding) {
horizontalPadding = 0;
@@ -264,11 +270,11 @@
bool disposePixbuf = false;
- if (format.ImageType == ImageType.Rgb56590 || format.ImageType ==
ImageType.Rgb565BE90) {
- pixbuf = pixbuf.RotateSimple
(Gdk.PixbufRotation.Counterclockwise);
+ if (format.Rotation > 0) {
+ pixbuf = Rotate (pixbuf, format.Rotation);
disposePixbuf = true;
}
-
+
if (pixbuf.Height != format.Height || pixbuf.Width !=
format.Width) {
int padX, padY;
Gdk.Pixbuf scaled = Scale (pixbuf, format.Width,
format.Height, out padX, out padY);
@@ -286,20 +292,18 @@
byte[] data = null;
- switch (format.ImageType) {
- case ImageType.Rgb565:
- case ImageType.Rgb56590:
+ switch (format.PixelFormat) {
+ case PixelFormat.Rgb565:
data = PackRgb565 (pixbuf, false);
break;
- case ImageType.Rgb565BE:
- case ImageType.Rgb565BE90:
+ case PixelFormat.Rgb565BE:
data = PackRgb565 (pixbuf, true);
break;
- case ImageType.IYUV:
+ case PixelFormat.IYUV:
data = PackIYUV (pixbuf);
break;
default:
- throw new ApplicationException ("Unknown image type: " +
format.ImageType);
+ throw new ApplicationException ("Unknown pixel format: " +
format.PixelFormat);
}
if (disposePixbuf) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches