RE: Fix for 687294 psdcmyk device does not writeresolution correctly to PSD files
"Dan Coby" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
Igor, >I can't review your algorithm because I have no knowledge about the PSD >format. >The syntax looks perfect. If you are really interested, I can send you a copy of the specifications. My copy of Photoshop includes a copy of the Photoshop SDK. The SDK includes the specifications. If you have Photoshop then you probably also have the specifications. >Don't know where it's fine to assume that HWResolution is an integer. >I would code > > (int) (pdev->HWResolution[0] * 0x10000 + 0.5); There is no assumption that HWResolution is an integer. It is defined as a 'float'. The value is cast to an integer only after multiplying by 0x10000. The cast is needed because Photoshop uses a 'fixed' format for storing resolution. The 'fixed' format consists of a 16 bit integer and a 16 bit fraction. The addition of 0.5 for rounding is minor but I have added it to the code. Dan -----Original Message----- From: Igor V. Melichev [mailto:[email protected]] Sent: Saturday, February 14, 2004 12:58 AM To: [email protected] Cc: [email protected] Subject: Re: [gs-code-review] Fix for 687294 psdcmyk device does not writeresolution correctly to PSD files Dan, I can't review your algorithm because I have no knowledge about the PSD format. The syntax looks perfect. Don't know where it's fine to assume that HWResolution is an integer. I would code (int) (pdev->HWResolution[0] * 0x10000 + 0.5); Igor. ----- Original Message ----- From: "Dan Coby" <[email protected]> To: "Gs-Code-Review" <[email protected]> Sent: Saturday, February 14, 2004 11:37 AM Subject: [gs-code-review] Fix for 687294 psdcmyk device does not writeresolution correctly to PSD files > > Fix for 687294 psdcmyk device does not write resolution correctly to PSD > files. > This change adds a 'ResolutionInfo structure' into the 'Image Resources' > section of the output file. This structure specifies the horizontal and > vertical > resolution of the image. (Note: Adobe's support of asymetric resolutions > is > poor.) > > > DETAILS. > Index: src/gdevpsd.c > =================================================================== > RCS file: /cvs/ghostscript/gs/src/gdevpsd.c,v > retrieving revision 1.5 > diff -u -r1.5 gdevpsd.c > --- src/gdevpsd.c 10 Jul 2003 22:32:04 -0000 1.5 > +++ src/gdevpsd.c 14 Feb 2004 08:31:26 -0000 > @@ -999,7 +999,8 @@ > chan_names_len += (separation_name->size + 1); > } > psd_write_32(xc, 12 + (chan_names_len + (chan_names_len % 2)) > - + (12 + (14*xc->n_extra_channels))); > + + (12 + (14*xc->n_extra_channels)) > + + 28); > psd_write(xc, (const byte *)"8BIM", 4); > psd_write_16(xc, 1006); /* 0x03EE */ > psd_write_16(xc, 0); /* PString */ > @@ -1035,6 +1036,19 @@ > psd_write_8(xc, 2); /* Don't know */ > psd_write_8(xc, 0); /* Padding - Always Zero */ > } > + /* Image resolution */ > + psd_write(xc, (const byte *)"8BIM", 4); > + psd_write_16(xc, 1005); /* 0x03ED */ > + psd_write_16(xc, 0); /* PString */ > + psd_write_32(xc, 16); /* Length */ > + /* Resolution is specified as a fixed 16.16 bits */ > + psd_write_32(xc, (int) (pdev->HWResolution[0] * 0x10000)); > + psd_write_16(xc, 1); /* width: 1 --> resolution is pixels per > inch */ > + psd_write_16(xc, 1); /* width: 1 --> resolution is pixels per > inch */ > + psd_write_32(xc, (int) (pdev->HWResolution[1] * 0x10000)); > + psd_write_16(xc, 1); /* height: 1 --> resolution is pixels per > inch */ > + psd_write_16(xc, 1); /* height: 1 --> resolution is pixels per > inch */ > + > /* Layer and Mask information */ > psd_write_32(xc, 0); > > _______________________________________________ > gs-code-review mailing list > [email protected] > http://www.ghostscript.com/mailman/listinfo/gs-code-review >