489
edits
Script 10k (talk | contribs) m (now the page point to the correct binary page) |
Script 10k (talk | contribs) (Algorithm to split images to fit in TXMB) |
||
Line 100: | Line 100: | ||
* Now we can right-click, load a selection, crop and save it as "..._N" (whereas N is a number from 0 to 5). | * Now we can right-click, load a selection, crop and save it as "..._N" (whereas N is a number from 0 to 5). | ||
* Let's redo crop, load another selection, save this piece, and so on. | * Let's redo crop, load another selection, save this piece, and so on. | ||
Algorithm to split images to fit in TXMB: | |||
The following algorithm seems to work correctly and generate resolutions that are the same used in Vanilla oni. The algorithm is currently used in Vago for TXMB creation. | |||
It works as follow: | |||
Try to fit 256x256 images in the TXMB until it's possible. When you aren't able to add any more 256x256 images you add the remaining resolution left to complete the TXMB. | |||
Example image 640x480: | |||
<pre>256x256 | 256x256 | 128x256 * | |||
256x224 ** | 256x224 ** | 128x224* **</pre> | |||
<nowiki>*</nowiki>where we add 128 which is the remaining resolution, we couldn't have added another 256 width resolution because it would overflow the TXMB 640 width | |||
<nowiki>**</nowiki>where we add 224 which is the remaining resolution, we couldn't have added another 256 width resolution because it would overflow the TXMB 480 height | |||
Algorithm pseudo code: | |||
<code> | |||
function getSplitSizes(int sideSize){ | |||
vector splitSizes; | |||
int remainingSize = sideSize; | |||
int regularSize = 256; | |||
while (remainingSize > 0){ | |||
if(remainingSize - regularSize < 0){ | |||
splitSizes.add(remainingSize); | |||
remainingSize = 0; | |||
} | |||
else{ | |||
splitSizes.add(regularSize); | |||
remainingSize = remainingSize - regularSize; | |||
} | |||
} | |||
return splitSizes; | |||
}</code> | |||
{{XML}} | {{XML}} |
edits