Jump to content

How did they do that?


FireController1847

Recommended Posts

Hmm. Why does this keep erroring me?

 

	public static void SetIcon(BufferedImage Icon32x, BufferedImage Icon16x) {

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	ImageIO.write(Icon32x, "png", baos);
	byte[] image1byte = baos.toByteArray();
	ByteBuffer image1 = ByteBuffer.wrap(image1byte);

	ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
	ImageIO.write(Icon16x, "png", baos2);
	byte[] image2byte = baos2.toByteArray();
    ByteBuffer image2 = ByteBuffer.wrap(image2byte);

	ByteBuffer[] list = new ByteBuffer[2];
	list[0] = image1;
	list[1] = image2;
	Display.setIcon(list);
}

I am on my journey of making a remake of matmos, as explained here.

Link to comment
Share on other sites

I changed it to jpg and it still errors. When I hover over the line that errors (the ImageIO.write), it'll give me two options:

 

Unhandled exception type IOException

 

- Add throw

- Add catch

 

ClientProxy.SetIcon(ImageIO.read(new File("src/Images/Tests/icon32.png")), ImageIO.read(new File("src/Images/Tests/icon32.png")));

 

public static void SetIcon(BufferedImage Icon32x, BufferedImage Icon16x) {

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	ImageIO.write(Icon32x, "jpg", baos);
	byte[] image1byte = baos.toByteArray();
	ByteBuffer image1 = ByteBuffer.wrap(image1byte);

	ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
	ImageIO.write(Icon16x, "jpg", baos2);
	byte[] image2byte = baos2.toByteArray();
    ByteBuffer image2 = ByteBuffer.wrap(image2byte);

	ByteBuffer[] list = new ByteBuffer[2];
	list[0] = image1;
	list[1] = image2;
	Display.setIcon(list);
}

I am on my journey of making a remake of matmos, as explained here.

Link to comment
Share on other sites

No what it does is take the image and turn it info a ByteBuffer.

 

The below still set the icon of those bytebuffers,

 

ByteBuffer[] list = new ByteBuffer[2];
list[0] = image1;
list[1] = image2;
Display.setIcon(list);

 

Below, before above creates the byte buffers,

 

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	ImageIO.write(Icon32x, "jpg", baos);
	byte[] image1byte = baos.toByteArray();
	ByteBuffer image1 = ByteBuffer.wrap(image1byte);

	ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
	ImageIO.write(Icon16x, "jpg", baos2);
	byte[] image2byte = baos2.toByteArray();
       ByteBuffer image2 = ByteBuffer.wrap(image2byte);

I am on my journey of making a remake of matmos, as explained here.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.