-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9984c1c
commit 2b14e48
Showing
15 changed files
with
891 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/github/fabriciofx/cactoos/pdf/png/Body.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.fabriciofx.cactoos.pdf.png; | ||
|
||
import com.github.fabriciofx.cactoos.pdf.Content; | ||
|
||
public interface Body extends Content { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/github/fabriciofx/cactoos/pdf/png/BytesAsInteger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.fabriciofx.cactoos.pdf.png; | ||
|
||
import org.cactoos.Bytes; | ||
import org.cactoos.Scalar; | ||
|
||
public final class BytesAsInteger implements Scalar<Integer> { | ||
private final Bytes bytes; | ||
|
||
public BytesAsInteger(final byte[] bytes) { | ||
this(() -> bytes); | ||
} | ||
|
||
public BytesAsInteger(final Bytes bytes) { | ||
this.bytes = bytes; | ||
} | ||
|
||
@Override | ||
public Integer value() throws Exception { | ||
final byte[] raw = this.bytes.asBytes(); | ||
return ((raw[0] & 0xFF) << 24) | | ||
((raw[1] & 0xFF) << 16) | | ||
((raw[2] & 0xFF) << 8) | | ||
(raw[3] & 0xFF); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/github/fabriciofx/cactoos/pdf/png/Color.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (C) 2023 Fabrício Barros Cabral | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.fabriciofx.cactoos.pdf.png; | ||
|
||
public final class Color { | ||
private int type; | ||
|
||
public Color(final int type) { | ||
this.type = type; | ||
} | ||
|
||
public int type() { | ||
return this.type; | ||
} | ||
|
||
public String space() { | ||
final String space; | ||
switch(this.type) { | ||
case 0: | ||
case 4: | ||
space = "DeviceGray"; | ||
break; | ||
case 2: | ||
case 6: | ||
space = "DeviceRGB"; | ||
break; | ||
case 3: | ||
space = "Indexed"; | ||
break; | ||
default: | ||
space = "Unknown"; | ||
} | ||
return space; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/github/fabriciofx/cactoos/pdf/png/Header.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (C) 2023 Fabrício Barros Cabral | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.fabriciofx.cactoos.pdf.png; | ||
|
||
import org.cactoos.Bytes; | ||
import org.cactoos.Text; | ||
|
||
/** | ||
* PNG Image Header | ||
* | ||
* PNG Image Header Structure: | ||
* ---------------------------- | ||
* | ||
* Offset Length Field Name Description | ||
* --------------------------------------------- | ||
* 0 8 bytes Signature PNG file signature (137 80 78 71 13 10 26 10) | ||
* 8 4 bytes Chunk Length Length of the chunk data (excluding length and type) | ||
* 12 4 bytes Chunk Type Type of the chunk (e.g., IHDR for image header) | ||
* 16 4 bytes Width Width of the image in pixels | ||
* 20 4 bytes Height Height of the image in pixels | ||
* 24 1 byte Bit Depth Number of bits per sample | ||
* 25 1 byte Color Type Type of color encoding used | ||
* 26 1 byte Compression Compression method used | ||
* 27 1 byte Filter Method Filtering method used | ||
* 28 1 byte Interlace Method Interlace method used | ||
* | ||
* Additional chunks (not included in the header): | ||
* - Data chunks (IDAT) containing the image data | ||
* - Palette chunks (PLTE) for indexed-color images | ||
* - Transparency chunks (tRNS) for specifying transparency | ||
* - Textual information chunks (tEXt, iTXt) for metadata | ||
* - Other optional chunks for various purposes | ||
*/ | ||
public interface Header extends Text, Bytes { | ||
int length(); | ||
int width(); | ||
int height(); | ||
int depth(); | ||
Color color(); | ||
int compression(); | ||
int filter(); | ||
int interlacing(); | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/github/fabriciofx/cactoos/pdf/png/Img.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (C) 2023 Fabrício Barros Cabral | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.fabriciofx.cactoos.pdf.png; | ||
|
||
public interface Img { | ||
Header header() throws Exception; | ||
Body body() throws Exception; | ||
Palette palette() throws Exception; | ||
} |
Oops, something went wrong.