📄 imageofflineexample.java
字号:
//===========================================================================//= This example serves as a testbed for basic RGB image manipulation =//=-------------------------------------------------------------------------=//= Module history: =//= - August 8 2005 - Oscar Chavarro: Original base version =//= - August 2 2006 - Oscar Chavarro: comments added =//===========================================================================// Basic JDK classesimport java.io.File;// VSDK classesimport vsdk.toolkit.common.VSDK; // Utilitiesimport vsdk.toolkit.media.RGBImage; // Model elementsimport vsdk.toolkit.io.image.ImagePersistence; // Persistence elementspublic class ImageOfflineExample { private static void performImageOperation1(RGBImage img) { int x, y; int xSize, ySize; byte r, g, b; xSize = img.getXSize(); ySize = img.getYSize(); for ( y = 0; y < ySize/2; y++ ) { for ( x = 0; x < xSize/2; x++ ) { r = VSDK.unsigned8BitInteger2signedByte(255); g = VSDK.unsigned8BitInteger2signedByte(0); b = VSDK.unsigned8BitInteger2signedByte(0); img.putPixel(x, y, r, g, b); } } } public static void main (String[] args) { RGBImage img = null; String imageFilename = "../../../etc/images/render.jpg"; try { img = ImagePersistence.importRGB(new File(imageFilename)); } catch (Exception e) { System.err.println("Error: could not read the image file \"" + imageFilename + "\"."); System.err.println("Check you have access to that file from current working directory."); System.err.println(e); System.exit(0); } performImageOperation1(img); ImagePersistence.exportJPG(new File("output.jpg"), img); }}//===========================================================================//= EOF =//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -