Java Code Examples for javax.imageio.ImageIO.setUseCache()

The following are Jave code examples for showing how to use setUseCache() of the javax.imageio.ImageIO class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.field_181038_N = gameConfig.userInfo.field_181172_c;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex)).getResourceMap());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    logger.info("Setting user: " + this.session.getUsername());
    logger.info("(Session ID is " + this.session.getSessionID() + ")");
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = new IntegratedServer(this);

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
}
 
Example 2
Project: BaseClient   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.field_181038_N = gameConfig.userInfo.field_181172_c;
    this.mcDefaultResourcePack = new DefaultResourcePack((new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex)).getResourceMap());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    logger.info("Setting user: " + this.session.getUsername());
    logger.info("(Session ID is " + this.session.getSessionID() + ")");
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = new IntegratedServer(this);

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
}
 
Example 3
Project: BaseClient   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig) {
	theMinecraft = this;
	this.mcDataDir = gameConfig.folderInfo.mcDataDir;
	this.fileAssets = gameConfig.folderInfo.assetsDir;
	this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
	this.launchedVersion = gameConfig.gameInfo.version;
	this.twitchDetails = gameConfig.userInfo.userProperties;
	this.field_181038_N = gameConfig.userInfo.field_181172_c;
	this.mcDefaultResourcePack = new DefaultResourcePack(
			(new ResourceIndex(gameConfig.folderInfo.assetsDir, gameConfig.folderInfo.assetIndex))
					.getResourceMap());
	this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
	this.sessionService = (new YggdrasilAuthenticationService(gameConfig.userInfo.proxy,
			UUID.randomUUID().toString())).createMinecraftSessionService();
	this.session = gameConfig.userInfo.session;
	logger.info("Setting user: " + this.session.getUsername());
	logger.info("(Session ID is " + this.session.getSessionID() + ")");
	this.isDemo = gameConfig.gameInfo.isDemo;
	this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
	this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
	this.tempDisplayWidth = gameConfig.displayInfo.width;
	this.tempDisplayHeight = gameConfig.displayInfo.height;
	this.fullscreen = gameConfig.displayInfo.fullscreen;
	this.jvm64bit = isJvm64bit();
	this.theIntegratedServer = new IntegratedServer(this);

	if (gameConfig.serverInfo.serverName != null) {
		this.serverName = gameConfig.serverInfo.serverName;
		this.serverPort = gameConfig.serverInfo.serverPort;
	}

	ImageIO.setUseCache(false);
	Bootstrap.register();
}
 
Example 4
Project: Zombe-Modpack   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    LOGGER.debug("(Session ID is {})", new Object[] {this.session.getSessionID()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
    
    //-ZMod-core----------------------------------------------------------
    ZHandle.onMinecraftInit(this);
    //--------------------------------------------------------------------
}
 
Example 5
Project: OpenJSharp   File: InputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    InputType t = (InputType)env.getModifier(generalSourceRoot);
    inputType = t.getType();
}
 
Example 6
Project: OpenJSharp   File: OutputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    OutputType t = (OutputType)env.getModifier(generalDestRoot);
    outputType = t.getType();
}
 
Example 7
Project: jdk8u-jdk   File: InputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    InputType t = (InputType)env.getModifier(generalSourceRoot);
    inputType = t.getType();
}
 
Example 8
Project: jdk8u-jdk   File: OutputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    OutputType t = (OutputType)env.getModifier(generalDestRoot);
    outputType = t.getType();
}
 
Example 9
Project: openjdk-jdk10   File: InputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    InputType t = (InputType)env.getModifier(generalSourceRoot);
    inputType = t.getType();
}
 
Example 10
Project: openjdk-jdk10   File: OutputTests.java   View Source Code Vote up 5 votes
Context(TestEnvironment env, Result result) {
    size = env.getIntValue(sizeList);
    if (hasImageIO) {
        if (env.getModifier(useCacheTog) != null) {
            ImageIO.setUseCache(env.isEnabled(useCacheTog));
        }
    }

    OutputType t = (OutputType)env.getModifier(generalDestRoot);
    outputType = t.getType();
}
 
Example 11
Project: openjdk-jdk10   File: AppContextTest.java   View Source Code Vote up 5 votes
public void run() {
//          System.out.println("Thread " + threadName + " in thread group " +
//                             getThreadGroup().getName());

        // Create a new AppContext as though we were an applet
        SunToolkit.createNewAppContext();

        // Get default registry and store reference
        this.registry = IIORegistry.getDefaultInstance();

        for (int i = 0; i < 10; i++) {
//              System.out.println(threadName +
//                                 ": setting cache parameters to " +
//                                 useCache + ", " + cacheDirectory);
            ImageIO.setUseCache(useCache);
            ImageIO.setCacheDirectory(cacheDirectory);

            try {
                sleep(1000L);
            } catch (InterruptedException e) {
            }

//              System.out.println(threadName + ": reading cache parameters");
            boolean newUseCache = ImageIO.getUseCache();
            File newCacheDirectory = ImageIO.getCacheDirectory();
            if (newUseCache != useCache ||
                newCacheDirectory != cacheDirectory) {
//                  System.out.println(threadName + ": got " +
//                                     newUseCache + ", " +
//                                     newCacheDirectory);
//                  System.out.println(threadName + ": crosstalk encountered!");
                gotCrosstalk = true;
            }
        }
    }
 
Example 12
Project: openjdk-jdk10   File: CreateMemoryCacheOutputStream.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    ImageIO.setUseCache(false);
    OutputStream os = new ByteArrayOutputStream();
    ImageOutputStream stream = null;
    try {
        stream = ImageIO.createImageOutputStream(os);
    } catch (Exception e) {
        throw new RuntimeException("Got exception " + e);
    }
    if (stream == null) {
        throw new RuntimeException("Got null stream!");
    }
}
 
Example 13
Project: Mevius-IO   File: MeviusImagePacket.java   View Source Code Vote up 5 votes
public MeviusImagePacket(BufferedImage image) throws IOException, ClassNotFoundException {
	ByteArrayOutputStream baos = new ByteArrayOutputStream(image.getHeight() * image.getWidth());
	ImageIO.setUseCache(false);
	ImageIO.write(image, "jpg", baos);
	imageBuffer = baos.toByteArray();
	baos.flush();
	baos.close();
}
 
Example 14
Project: Backmemed   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    LOGGER.debug("(Session ID is {})", new Object[] {this.session.getSessionID()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Locale.setDefault(Locale.ROOT);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
}
 
Example 15
Project: CustomWorldGen   File: Minecraft.java   View Source Code Vote up 5 votes
public Minecraft(GameConfiguration gameConfig)
{
    theMinecraft = this;
    this.mcDataDir = gameConfig.folderInfo.mcDataDir;
    this.fileAssets = gameConfig.folderInfo.assetsDir;
    this.fileResourcepacks = gameConfig.folderInfo.resourcePacksDir;
    this.launchedVersion = gameConfig.gameInfo.version;
    this.versionType = gameConfig.gameInfo.versionType;
    this.twitchDetails = gameConfig.userInfo.userProperties;
    this.profileProperties = gameConfig.userInfo.profileProperties;
    this.mcDefaultResourcePack = new DefaultResourcePack(gameConfig.folderInfo.getAssetsIndex());
    this.proxy = gameConfig.userInfo.proxy == null ? Proxy.NO_PROXY : gameConfig.userInfo.proxy;
    this.sessionService = (new YggdrasilAuthenticationService(this.proxy, UUID.randomUUID().toString())).createMinecraftSessionService();
    this.session = gameConfig.userInfo.session;
    LOGGER.info("Setting user: {}", new Object[] {this.session.getUsername()});
    this.isDemo = gameConfig.gameInfo.isDemo;
    this.displayWidth = gameConfig.displayInfo.width > 0 ? gameConfig.displayInfo.width : 1;
    this.displayHeight = gameConfig.displayInfo.height > 0 ? gameConfig.displayInfo.height : 1;
    this.tempDisplayWidth = gameConfig.displayInfo.width;
    this.tempDisplayHeight = gameConfig.displayInfo.height;
    this.fullscreen = gameConfig.displayInfo.fullscreen;
    this.jvm64bit = isJvm64bit();
    this.theIntegratedServer = null;

    if (gameConfig.serverInfo.serverName != null)
    {
        this.serverName = gameConfig.serverInfo.serverName;
        this.serverPort = gameConfig.serverInfo.serverPort;
    }

    ImageIO.setUseCache(false);
    Bootstrap.register();
    this.dataFixer = DataFixesManager.createFixer();
}
 
Example 16
Project: openjdk-jdk10   File: DeleteOnExitTest.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws IOException {
    ByteArrayInputStream is =
        new ByteArrayInputStream(new byte[100]);
    ByteArrayOutputStream os =
        new ByteArrayOutputStream();

    String tmp = System.getProperty("java.io.tmpdir", ".");
    System.out.println("tmp: " + tmp);

    // count number of files before test
    ImageIO.setUseCache(true);
    ImageIO.setCacheDirectory(new File(tmp));

    File tmpDir = ImageIO.getCacheDirectory();
    System.out.println("tmpDir is " + tmpDir);
    int fnum_before = tmpDir.list().length;
    System.out.println("Files before test: " + fnum_before);

    ImageInputStream iis =
        ImageIO.createImageInputStream(is);
    System.out.println("iis = " + iis);

    ImageInputStream iis2 =
        ImageIO.createImageInputStream(is);

    ImageOutputStream ios =
        ImageIO.createImageOutputStream(os);
    System.out.println("ios = " + ios);

    ImageOutputStream ios2 =
        ImageIO.createImageOutputStream(os);

    iis2.close();
    ios2.close();
    int fnum_after = tmpDir.list().length;
    System.out.println("Files after test: " + fnum_after);

    if (fnum_before == fnum_after) {
        throw new RuntimeException("Test failed: cache was not used.");
    }
}
 
Example 17
Project: openjdk-jdk10   File: StreamFlush.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws IOException {
    ImageIO.setUseCache(true);

    // Create a FileImageOutputStream from a FileOutputStream
    File temp1 = File.createTempFile("imageio", ".tmp");
    temp1.deleteOnExit();
    ImageOutputStream fios = ImageIO.createImageOutputStream(temp1);

    // Create a FileCacheImageOutputStream from a BufferedOutputStream
    File temp2 = File.createTempFile("imageio", ".tmp");
    temp2.deleteOnExit();
    FileOutputStream fos2 = new FileOutputStream(temp2);
    BufferedOutputStream bos = new BufferedOutputStream(fos2);
    ImageOutputStream fcios1 = ImageIO.createImageOutputStream(bos);

    // Create a FileCacheImageOutputStream from a ByteArrayOutputStream
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageOutputStream fcios2 = ImageIO.createImageOutputStream(baos);

    BufferedImage bi =
        new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);

    ImageIO.write(bi, "jpg", fios); // No bug, check it anyway
    ImageIO.write(bi, "png", fcios1); // Bug 4414990
    ImageIO.write(bi, "jpg", fcios2); // Bug 4415041

    // It should not be necessary to flush any of the streams
    // If flushing does make a difference, it indicates a bug
    // in the writer or the stream implementation

    // Get length of temp1 before and after flushing
    long file1NoFlushLength = temp1.length();
    fios.flush();
    long file1FlushLength = temp1.length();

    // Get length of temp2 before and after flushing
    long file2NoFlushLength = temp2.length();
    fcios1.flush();
    bos.flush();
    long file2FlushLength = temp2.length();

    byte[] b0 = baos.toByteArray();
    int cacheNoFlushLength = b0.length;
    fcios2.flush();
    byte[] b1 = baos.toByteArray();
    int cacheFlushLength = b1.length;

    if (file1NoFlushLength != file1FlushLength) {
        // throw new RuntimeException
        System.out.println
            ("FileImageOutputStream not flushed!");
    }

    if (file2NoFlushLength != file2FlushLength) {
        // throw new RuntimeException
        System.out.println
         ("FileCacheImageOutputStream/BufferedOutputStream not flushed!");
    }

    if (cacheNoFlushLength != cacheFlushLength) {
        // throw new RuntimeException
        System.out.println
        ("FileCacheImageOutputStream/ByteArrayOutputStream not flushed!");
    }
}