39 ! |
39 ! |
40 |
40 |
41 documentation |
41 documentation |
42 " |
42 " |
43 This class will provide methods for loading and saving PNG pictures. |
43 This class will provide methods for loading and saving PNG pictures. |
44 It is currenty unfinished (interlaced image support is missing). |
44 It is currenty unfinished (interlaced image support is missing resp. being developed as we encounter more formats). |
45 In the meantime, use a pngtoXXX converter for interlaced images. |
45 In the meantime, use a pngtoXXX converter for interlaced images, and read XXX. |
46 |
46 |
47 [caveats:] |
47 [caveats:] |
48 writer ignores any mask (for now). |
48 writer ignores any mask (for now). |
49 writer only generates unfiltered rows or interlace data |
49 writer only generates unfiltered rows or interlace data |
50 |
50 |
547 #copyPixelsIndexed:at:by: |
547 #copyPixelsIndexed:at:by: |
548 #copyPixelsGrayAlpha:at:by: |
548 #copyPixelsGrayAlpha:at:by: |
549 nil |
549 nil |
550 #copyPixelsRGBA:at:by: |
550 #copyPixelsRGBA:at:by: |
551 ) at:colorType + 1. |
551 ) at:colorType + 1. |
552 self perform:(s asSymbol) with:y with:startX with:incX |
552 self perform:s with:y with:startX with:incX |
553 |
553 |
554 "Modified: / 03-05-2011 / 12:02:45 / cg" |
554 "Modified: / 03-05-2011 / 12:02:45 / cg" |
555 ! |
555 ! |
556 |
556 |
557 copyPixelsRGBA:y at:startX by:incX |
557 copyPixelsRGBA:y at:startX by:incX |
558 "Handle interlaced pixels of supported colorTypes. |
558 "Handle interlaced pixels of supported colorTypes. |
559 Untested code - please verify" |
559 Untested code - please verify" |
560 |
560 |
561 |srcIndex nPixels dstIndex n r g b a| |
561 |srcIndex nPixels dstIndex dstInc| |
562 |
562 |
563 srcIndex := 1. |
563 srcIndex := 1. |
564 dstIndex := y * bytesPerScanline. |
564 dstIndex := (y * bytesPerScanline) + (startX * 4) + 1. |
565 n := width // incX. |
565 dstInc := incX * 4. |
566 |
566 |
567 nPixels := thisScanline size. |
567 nPixels := thisScanline size. |
568 [srcIndex < nPixels] whileTrue:[ |
568 [srcIndex < nPixels] whileTrue:[ |
569 r := thisScanline at:srcIndex. |
569 data replaceFrom:dstIndex to:dstIndex+3 with:thisScanline startingAt:srcIndex. |
570 g := thisScanline at:srcIndex+1. |
|
571 b := thisScanline at:srcIndex+2. |
|
572 a := thisScanline at:srcIndex+3. |
|
573 data replaceFrom:dstIndex+1 to:(dstIndex+3) with:thisScanline startingAt:srcIndex. |
|
574 srcIndex := srcIndex + 4. |
570 srcIndex := srcIndex + 4. |
575 dstIndex := dstIndex + (incX * 4) |
571 dstIndex := dstIndex + dstInc |
576 ]. |
572 ]. |
577 ! ! |
573 ! ! |
578 |
574 |
579 !PNGReader methodsFor:'private-reading'! |
575 !PNGReader methodsFor:'private-reading'! |
580 |
576 |
904 ! ! |
900 ! ! |
905 |
901 |
906 !PNGReader class methodsFor:'documentation'! |
902 !PNGReader class methodsFor:'documentation'! |
907 |
903 |
908 version |
904 version |
909 ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.35 2014-11-15 16:34:26 cg Exp $' |
905 ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.36 2014-12-22 12:00:09 cg Exp $' |
910 ! |
906 ! |
911 |
907 |
912 version_CVS |
908 version_CVS |
913 ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.35 2014-11-15 16:34:26 cg Exp $' |
909 ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.36 2014-12-22 12:00:09 cg Exp $' |
914 ! ! |
910 ! ! |
915 |
911 |
916 |
912 |
917 PNGReader initialize! |
913 PNGReader initialize! |