Created
December 24, 2019 08:09
-
-
Save aspose-com-gists/ba8e70ccced6ac4a71f57cc3cfed2321 to your computer and use it in GitHub Desktop.
Aspsoe.Imaging for .NET and Java 19.12 Blog
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
// Setting a memory limit of 10 megabytes for target created image | |
// JP2 codec | |
ImageOptionsBase createOptions = new Jpeg2000Options { Codec = Jpeg2000Codec.Jp2 }; | |
createOptions.BufferSizeHint = 10; | |
createOptions.Source = new FileCreateSource("createdFile.jp2", false); | |
using (var image = Image.Create(createOptions, 1000, 1000)) { | |
image.Save(); // save to same location | |
} | |
// J2K codec | |
ImageOptionsBase createOptions = new Jpeg2000Options { Codec = Jpeg2000Codec.J2K }; | |
createOptions.BufferSizeHint = 10; | |
createOptions.Source = new FileCreateSource("createdFile.j2k", false); | |
using (var image = Image.Create(createOptions, 1000, 1000)) { | |
image.Save(); // save to same location | |
} |
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
// Setting a memory limit of 10 megabytes for target created image | |
// JP2 codec | |
try(Jpeg2000Options createOptions = new Jpeg2000Options()) | |
{ | |
createOptions.setCodec(Jpeg2000Codec.Jp2); | |
createOptions.setBufferSizeHint(10); | |
createOptions.setSource(new FileCreateSource("createdFile.jp2", false)); | |
try (Image image = Image.create(createOptions, 1000, 1000)) | |
{ | |
image.save(); // save to same location | |
} | |
} | |
// J2K codec | |
try(Jpeg2000Options createOptions = new Jpeg2000Options()) | |
{ | |
createOptions.setCodec(Jpeg2000Codec.J2K); | |
createOptions.setBufferSizeHint(10); | |
createOptions.setSource(new FileCreateSource("createdFile.j2k", false)); | |
try (Image image = Image.create(createOptions, 1000, 1000)) | |
{ | |
image.save(); // save to same location | |
} | |
} |
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
// Setting a memory limit of 50 megabytes for target loaded image | |
using (DjvuImage image = (DjvuImage)Image.Load("test.djvu", new LoadOptions { BufferSizeHint = 50 })) | |
{ | |
for (int pageNum = 0; pageNum < image.Pages.Length; pageNum++) { | |
image.Pages[pageNum].Save("page" + pageNum + ".png", new PngOptions()); | |
} | |
} |
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
// Setting a memory limit of 50 megabytes for target loaded image | |
try (DjvuImage image = (DjvuImage)Image.load("test.djvu", new LoadOptions() {{ setBufferSizeHint(50); }})) | |
{ | |
int pageNum = 0; | |
for (DjvuPage page : image.getPages()) | |
{ | |
page.save("page" + pageNum + ".png", new PngOptions()); | |
pageNum++; | |
} | |
} |
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
// Setting a memory limit of 10 megabytes for target loaded image | |
// JP2 codec | |
using (Image image = Image.Load("inputFile.jp2", new LoadOptions() { BufferSizeHint = 10 })) { | |
image.Save("outputFile.jp2"); | |
} | |
// J2K codec | |
using (Image image = Image.Load("inputFile.j2k", new LoadOptions() { BufferSizeHint = 10 })) { | |
image.Save("outputFile.j2k"); | |
} |
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
// Setting a memory limit of 10 megabytes for target loaded image | |
// JP2 codec | |
try (Image image = Image.load("inputFile.jp2", new LoadOptions() {{ setBufferSizeHint(10); }})) | |
{ | |
image.save("outputFile.jp2"); | |
} | |
// J2K codec | |
try (Image image = Image.load("inputFile.j2k", new LoadOptions() {{ setBufferSizeHint(10); }})) | |
{ | |
image.save("outputFile.j2k"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment