aliens

Author Topic: PCK View issues  (Read 18166 times)

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
PCK View issues
« on: June 24, 2014, 08:19:36 pm »
I'm getting a lot of error messages using PCKView. At first I thought it had something to do with the graphics using the wrong palette but now I'm more and more convinced that there may be something wrong. Essentially everytime I add additional BMPs or replace existing ones I get the error message attached below. And it actually seems cumulative. Today I rebuilt a PCK file from one of the original files and at first I was getting no errors but now after 150 images replaced I can't seem to do anything. Sometimes the same image will be properly saved and I can load the PCK file afterwards, other times I'll use the image to replace another one and after saving I can't reload it.

If anyone could look into PCKView and try to find out what's happening I would appreciate it. I'm wasting a lot of time with these trial and error experiments since I'm pretty sure I eliminated the possibilities that my .bmps are causing the problem.

Offline Falko

  • Commander
  • *****
  • Posts: 802
    • View Profile
Re: PCK View issues
« Reply #1 on: June 24, 2014, 09:22:42 pm »
sotty i cant help with the issue itself.
but why do you build PCK files in openxcom? the programm can combine png/gif just fine in "virtual?" old/new PCK data

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #2 on: June 24, 2014, 09:43:12 pm »
sotty i cant help with the issue itself.
but why do you build PCK files in openxcom? the programm can combine png/gif just fine in "virtual?" old/new PCK data

I need to build the PCK files in order to use them together with the MCDs for Map View.

I'm trying to even use MCDEdit to load the PNGs but the images get messed up after I save. Either the PCK files have a maximum number of images they can hold (but I had this behavior yesterday and I managed to avoid it today) or I'm clueless about what's happening.

EDIT: After several retries I'm more inclined to think I've reached some sort of internal limit since it's the best explanation for all the odd behavior I got. My current PCK file has 142 images, while the biggest PCK files on UFO/TFTD have 133 images so it's likely that's the explanation.
« Last Edit: June 24, 2014, 10:24:53 pm by Hobbes »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #3 on: June 25, 2014, 01:19:09 am »
I am available to debug PCKView

I need your files and istructions to reproduce the issues


Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #4 on: June 25, 2014, 01:37:20 am »
I am available to debug PCKView

I need your files and istructions to reproduce the issues

Thank you for the assistance :)

I've attached a .zip file containing the PCK/TAB/MCD files and 4 BMP files I was trying to add.

Essentially open the AREA51Z.PCK file and add (not replace but add a new image) one or more of the .BMP files and save it under PCK format under a different name. Afterwards open the new PCK and you should get the error message I previously attached.

If you have MCDEdit try opening the new AREA51Z MCD file and check how the images start getting garbled.
« Last Edit: June 25, 2014, 01:39:08 am by Hobbes »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #5 on: June 25, 2014, 02:12:25 am »
I reproduced it
Exception was fired in this methods, there is a possibility that  the problem is in the TabFile
The exception was fired at the end, I add a comment

Code: [Select]

public class PckFile:XCImageCollection
{
private int bpp;
public static readonly string TAB_EXT = ".tab";

public PckFile(Stream pckFile, Stream tabFile,int bpp,Palette pal,int imgHeight,int imgWidth)
{
if(tabFile!=null)
tabFile.Position=0;

pckFile.Position=0;

byte[] info = new byte[pckFile.Length];
pckFile.Read(info,0,info.Length);
pckFile.Close();

this.bpp=bpp;

Pal=pal;

uint[] offsets;

if(tabFile!=null)
{
offsets= new uint[(tabFile.Length/bpp)+1];
BinaryReader br = new BinaryReader(tabFile);

if(bpp==2)
for(int i=0;i<tabFile.Length/bpp;i++)
offsets[i] = br.ReadUInt16();
else
for(int i=0;i<tabFile.Length/bpp;i++)
offsets[i] = br.ReadUInt32();                                      https://STEP HERE
br.Close();
}
else
{
offsets = new uint[2];
offsets[0]=0;
}

offsets[offsets.Length-1] = (uint)info.Length;

for(int i=0;i<offsets.Length-1;i++)
{
byte[] imgDat = new byte[offsets[i+1]-offsets[i]];

for(int j=0;j<imgDat.Length;j++)
imgDat[j] = info[offsets[i]+j];                  https://EXCEPTION: bpp = 4, i = 0,  j = 0, offset[0] = 34734080

Add(new PckImage(i,imgDat,pal,this,imgHeight,imgWidth));
}

pckFile.Close();
if(tabFile!=null)
tabFile.Close();
}

now i am sorry but i must go to sleep
tomorrow I will check it better, before I must study MCD/PCK file format to understand the problem
« Last Edit: June 25, 2014, 10:09:50 am by davide »

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #6 on: June 25, 2014, 02:30:36 am »
If you have MCDEdit try opening the new AREA51Z MCD file and check how the images start getting garbled.

I have exe of MCDEdit 1.2 by Volutarr, it run but  i am not able to use it:
 I dont found menu to open a PCK :-[


Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #7 on: June 25, 2014, 02:38:18 am »
I have exe of MCDEdit 1.2 by Volutarr, it run but  i am not able to use it:
 I dont found menu to open a PCK :-[

Open the AREA51Z.MCD file and click on one of the images on the middle. It will display all the images on PCK file.

Good night and thanks for the assistance :)

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #8 on: June 25, 2014, 08:17:23 am »
Yesterday I did not copy files into MCDEdit folder.

Starting MCD file contains 137 tiles instead starting pck has 141 tiles

is it correct ?



Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #9 on: June 25, 2014, 11:02:43 am »
Yesterday I did not copy files into MCDEdit folder.

Starting MCD file contains 137 tiles instead starting pck has 141 tiles

is it correct ?

Yes. Tiles can use more than 1 image if they are animated. In that case, the 4 extra images on the PCK files are used for the sliding doors animations.

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #10 on: June 25, 2014, 11:54:01 am »
Thanks

diuring lunch time I will check it

Offline pmprog

  • Commander
  • *****
  • Posts: 647
  • Contributor
    • View Profile
    • Polymath Programming
Re: PCK View issues
« Reply #11 on: June 25, 2014, 12:20:48 pm »
Which PCKView app are you running? If it's the one from my pack (hmm, my github doesn't show a binary build for PCKView)

Anyway, I could try and take a look if I get time

Edit: Also: https://openxcom.org/forum/index.php?topic=2355.msg23676#msg23676

Offline davide

  • Commander
  • *****
  • Posts: 565
    • View Profile
Re: PCK View issues
« Reply #12 on: June 25, 2014, 12:37:58 pm »
Which PCKView app are you running? If it's the one from my pack (hmm, my github doesn't show a binary build for PCKView)


I get source on github

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #13 on: June 25, 2014, 12:50:49 pm »
Which PCKView app are you running? If it's the one from my pack (hmm, my github doesn't show a binary build for PCKView)

Anyway, I could try and take a look if I get time

Edit: Also: https://openxcom.org/forum/index.php?topic=2355.msg23676#msg23676

I got the version posted on that thread you mentioned.

Offline Hobbes

  • Commander
  • *****
  • Posts: 2101
  • Infiltration subroutine in progress
    • View Profile
Re: PCK View issues
« Reply #14 on: June 26, 2014, 09:18:20 pm »
So guys, any ideas whether this issue is related to PCK file capability or a bug?