Better Sprite Packer

This tutorial is on how to use this program with your client.

https://www.rune-server.ee/runescape-development/rs2-client/tools/626093-better-sprite-packer.html

AZQao8c.png


If you don't already have bsp version 1.48 download it
http://www.mediafire.com/file/dl7r1ff5b6i7b6n/bsp_1.48.jar

Step 1: Converting your .idx and .dat files into the updated format

If you are currently using Galkon's format (sprites are in a .idx and .dat) then download my previous version of bsp found here.
http://www.mediafire.com/file/2loev5asxpsamhf/bsp_1.44.jar

Use bsp_1.44 to load your .idx and .dat

v7EYCCW.png


once you have that loaded dump them into a folder.

9xW168Q.png


You should now have all of your sprites into a folder like this

2yQ5U2p.png


if you do then open up bsp_1.48 and load all of those images

cImutuD.png


then pack them.

agKIWD4.png


Now your sprites are in the updated format, now we have to make your client read them properly.

Next download these dependencies to add to your client, we have to use dependencies because java doesn't have support for LZMA2 compression yet. (hopefully in the future they will add it)

https://www.mediafire.com/?gcn1cwinel5ipeu

Next replace your SpriteLoader with this

Code:
package com.battleos;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;

public final class SpriteLoader {

	public static Sprite[] sprites;

	public static int totalSprites;

	public static void load() {
		Buffer data = new Buffer(FileUtils.readFile(SignLink.findcachedir() + "main_file_sprites.dat"));

		try (DataInputStream dataFile = new DataInputStream(new XZCompressorInputStream(new ByteArrayInputStream(data.buffer)))) {

			int totalSprites = dataFile.readInt();

			sprites = new Sprite[totalSprites];

			for (int index = 0; index < totalSprites; index++) {
				sprites[index] = SpriteLoader.decode(dataFile);
				
				sprites[index].setTransparency(255, 0, 255);
			}

			System.out.println("Sprites Loaded: " + totalSprites);
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}

	private static Sprite decode(DataInputStream dat) throws IOException {

		Sprite sprite = new Sprite();

		while (true) {

			byte opcode = dat.readByte();

			if (opcode == 0) {
				return sprite;
			} else if (opcode == 1) {
				sprite.setId(dat.readShort());
			} else if (opcode == 2) {
				sprite.setName(dat.readUTF());
			} else if (opcode == 3) {
				sprite.setWidth(dat.readShort());
			} else if (opcode == 4) {
				sprite.setHeight(dat.readShort());
			} else if (opcode == 5) {
				sprite.setOffsetX(dat.readShort());
			} else if (opcode == 6) {
				sprite.setOffsetY(dat.readShort());
			} else if (opcode == 7) {

				int indexLength = dat.readInt();

				int[] pixels = new int[indexLength];

				for (int i = 0; i < pixels.length; i++) {
					pixels[i] = dat.readInt();
				}

				sprite.pixels = pixels;
			}
		}
	}

}

Next in your sprite class add this

Code:
	private int idenfier;
	
	private String name;
	
	public Sprite() {
	}	

	public int getId() {
		return idenfier;
	}

	public void setId(int id) {
		this.idenfier = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int[] getPixels() {
		return pixels;
	}

	public void setPixels(int[] pixels) {
		this.pixels = pixels;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getOffsetX() {
		return offsetX;
	}

	public void setOffsetX(int offsetX) {
		this.offsetX = offsetX;
	}

	public int getOffsetY() {
		return offsetY;
	}

	public void setOffsetY(int offsetY) {
		this.offsetY = offsetY;
	}

you'll have to rename your variables example offsetX is drawOffsetX and pixels is raster or myPixels, width is myWidth, everything else i just renaming

If you are totally lost, I took the Battle-OS project and updated to use my sprite format so you can reference that.
https://www.mediafire.com/?h3zv272p5ce3vv7
 
Did you fix the time it takes to actually load the sprites from 1.46?

Yes, in version 1.48 I switched from GZip to XZ (LZMA2) and tweeked the #decoding method. When I ran tests on this client https://github.com/chadalen/astraeus-client I didn't have any issues but noticed it decompressed a lot faster and had a lot better compression ratio as well.

I also tested on the Battle-OS client and it loaded the sprites fast. Try the newer version and let me know if you notice a difference.
 
Awesome, how many images were you testing though? on 1.46 i think I had like 800 images and it took 9 seconds to decode it.

The tests I ran was with 4,277 sprites. I believe it was from the #122 sprite dump. Though most of those sprites aren't very big so depending on how large your sprites are it may take longer to load.

If you're curious how long it will take to load the sprites you can use the Battle-OS client and add your sprites to it.
https://www.mediafire.com/?h3zv272p5ce3vv7

This client also works with my sprite packer
https://github.com/chadalen/astraeus-client
 
The tests I ran was with 4,277 sprites. I believe it was from the #122 sprite dump. Though most of those sprites aren't very big so depending on how large your sprites are it may take longer to load.

If you're curious how long it will take to load the sprites you can use the Battle-OS client and add your sprites to it.
https://www.mediafire.com/?h3zv272p5ce3vv7

This client also works with my sprite packer
https://github.com/chadalen/astraeus-client
I'll give it a shot and get back to you with results.

Edit: Heres the results
Time taken to load images before: 546ms <-- Galkons way
Loaded a total of 805 cache sprites.
Sprites Loaded: 805
Time taken to load images After: 1026ms <-- 1.48
 
I'll give it a shot and get back to you with results.

Edit: Heres the results
Time taken to load images before: 546ms <-- Galkons way
Loaded a total of 805 cache sprites.
Sprites Loaded: 805
Time taken to load images After: 1026ms <-- 1.48

Yeah Galkons is going to be faster because it uses GZip and GZip has a really fast decompression time but has a pretty bad compression ratio. What's the file size comparison? Should be about 30% smaller than Galkons. Also is the 1026ms very noticeable compared to 546ms? Well it's definitely an improvement from 9 seconds haha
 
Yeah Galkons is going to be faster because it uses GZip and GZip has really fast decompression times but has a pretty bad compression ratio. What's the file size comparison? Also is the 1026ms very noticeable compared to 546ms?

The difference in time loading is negligible compared to 2,787kb previously to 1,448kb now.
 
  • Like
Reactions: CrazyPanda
Patch 1.49
  • I added text for the buttons so it's easier to know what each icon is for.
  • Rewrote the programs CSS. I chose to go with a darker theme so you can see the images better. I also think this looks more professional and cleaner.
  • Removed the progress bar, now you can see more of the image.
  • When you click a large image the program doesn't resize anymore, instead it's placed in a scollpane and you can pan around the image.
  • No longer can maximize the program (pointless to have the program maximized, the program isn't meant for 4k images)
  • Updated the GitHub page, you can see it here https://github.com/chadalen/better-sprite-packer

Media
lLGj3PD.png


7Q8bC3g.gif


Download
Release 1.49
 
Hey, i try to use ur tool but i have a problem.
Dumped my sprites with bsp 1.44 them loaded with 1.49 and build main_file_sprites.dat
when i run my client i get http://prntscr.com/eddri3
Spriteloader - http://pastebin.com/83jwdjvb
Sprite - http://pastebin.com/Yc53CCUJ

Errors info
http://prntscr.com/eddt8s
http://prntscr.com/eddtew
http://prntscr.com/eddtk1

Can someone help me ?? pls
In spriteloader class at the bottom, change:
Code:
sprite.pixels = pixels;
to
Code:
sprite.myPixels = pixels;

and in Sprite class use these instead:
Code:
	public int[] getPixels() {
		return myPixels;
	}

	public void setPixels(int[] pixels) {
		this.myPixels = pixels;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.myWidth = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.myHeight = height;
	}
 
  • Like
Reactions: CrazyPanda
In spriteloader class at the bottom, change:
Code:
sprite.pixels = pixels;
to
Code:
sprite.myPixels = pixels;

and in Sprite class use these instead:
Code:
	public int[] getPixels() {
		return myPixels;
	}

	public void setPixels(int[] pixels) {
		this.myPixels = pixels;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.myWidth = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.myHeight = height;
	}
Thank you Zion, Fixed my errors but now it wont load my sprites from main_file_sprites , using 1.49 but i can use version 1,48 and its fine :(
 

Users who are viewing this thread (total: 1, members: 0, guests: 1)