×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Readin from very big .bmp file

    Hi all,

    I,m trying read raw data from large bitmapfile (10000x10000 8-bits). But there's not enough memory on phone (CFbsBitamp::Create give error -4) to use CImageDecodet.

    Any ideas how to read raw data from .bmp file? So I could load only tiles I need from bitmap.

    I'm able to allocate HBufC8 but when I try to read my file, RFile::Read or other read functions stop reading after 4 first bytes 0x4D 0x42 0xDA 0xC4

    All help / idea's welcome.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Readin from very big .bmp file

    10000x10000 ~ 100 megabytes, most devices do not have such amount of RAM. Also note that the current 320x240 resolution is around 64 kilobytes, your tileset is a bit larger than 1300 full-screen images. Are you sure that it is necessary?
    The 4-bytes issue sounds strange. Exactly how do you try that reading?

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Re: Readin from very big .bmp file

    File I'm trying to load is map file. It could be possible to slice image to smaller parts, but I would have to go change all coordinate files too.

    What comes to 4 bytes is really 4 bits =) (Indexed BMP).

    Size of bitmap I'm trying to read is ~6MB

    Currently have tried following methods:
    1. CImageDecoder
    Code:
    iImageDecoder = CImageDecoder::FileNewL( iFs, aFileName );
    TInt w = iImageDecoder->FrameInfo().iOverallSizeInPixels.iWidth;
    TInt h = iImageDecoder->FrameInfo().iOverallSizeInPixels.iHeight;
    TInt b = iImageDecoder->FrameInfo().iBitsPerPixel;
    iBitmap = new (ELeave) CFbsBitmap();
    TInt err = iBitmap->Create(iImageDecoder->FrameInfo().iOverallSizeInPixels,iImageDecoder->FrameInfo().iFrameDisplayMode); 
     //Err is -4 here.
    		
    	iState = EEncoding;
    	iImageDecoder->Convert( &iStatus, *iBitmap );
    	SetActive();
    2. RFile
    Code:
    RFile file;
    TInt err = file.Open(iFs,aFileName,EFileRead);
    TInt iFsize;
    file.Size(iFsize);
    file.Close();
    	
    HBufC8* fileData = HBufC8::NewL(iFsize);
    TPtr8 buffer = fileData->Des();
    TInt readBytes =iFs.ReadFileSection(aFileName, 0, buffer, iFsize);
    //Only reads 4 bytes;
    //After read fileData contais BMÚe
    //in hex 0x4D42 0x65DA	
    
    //Same happens with following
    //TInt readBytes = file.Read(buffer,iFsize);
    //TInt l = fileData->Length();
    I Think there's some charachter's is bmp header that are same as EOF.
    I have also tried RFileBuf and CLineReader without success.

    My idea was to read only needed bytes from file and create bitmap of them.
    In this way i would not need to process whole bitmap, but only parts of it.
    To do this I would need pointer to start of pixels data in .bmp file.
    But I don't know any other way than first read file to HBUFC8.
    Last edited by jascco; 2008-05-15 at 07:29.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Readin from very big .bmp file

    Have you set EPOCHEAPSIZE (in the .mmp)? With the default 1 megabytes, I have some doubts if "HBufC8* fileData = HBufC8::NewL(iFsize);" succeeds.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Re: Readin from very big .bmp file

    Thank you for fast replies wizard_hu.

    I have set EPOCHEAPSIZE to:

    EPOCHEAPSIZE 0x1000000 0x2000000

    Forget to mention that I can't even get this work in emulator.

    Just tried with bmp size of 26KB's and result is same. When using RFile.

    There must be something wrong with my read method as 26 KB image can be proberly read to CFbsBitmap if I use CImageDecoder.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Readin from very big .bmp file

    If you run the code in the emulator it would be advisable to check:
    - err
    - iFSize
    - l (the length of data).
    I would write
    Code:
    RFile file;
    User::LeaveIfError(file.Open(iFs,aFileName,0));
    CleanupClosePushL(file);
    TInt size;
    User::LeaveIfError(file.Size(size));
    HBufC8 *fileData=HBufC8::NewLC(size);
    TPtr8 buffer = fileData->Des();
    User::LeaveIfError(file.Read(buffer));
    CleanupStack::Pop(); // fileData
    CleanupStack::PopAndDestroy(); // file

  7. #7
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Re: Readin from very big .bmp file

    Hi wizard_hu,

    tested with code you posted and 26KB bitmap

    User::LeaveIfError(file.Open(iFs,aFileName,0));
    -> OK

    User::LeaveIfError(file.Size(size));
    -> size = 26074 (OK)

    HBufC8 *fileData=HBufC8::NewLC(size);
    ->OK

    TInt err = file.Read(buffer);
    -> err = 0 (OK)

    buffer.Length() -> 1073767898
    fileData->Length() -> 26074
    fileData contais BMÚe
    -> Result bitmap is not read completely

    Any ideas?
    Next I'll try to open & save my bmp in photoshop, if my current format is in someway faulty. (Still wonder why CImageDecoder is succesfull)

  8. #8
    Registered User
    Join Date
    Dec 2005
    Location
    Finland
    Posts
    109

    Re: Readin from very big .bmp file

    OK, I go this work, eventually there wasn't anything wrong,
    data just showed to be only BMÚe but buffer is filled correctly.

    I tested this by writing data to another file, and result is perfect bitmap.

    I'll try now with big bitmap, and post result.

    Thanks wizard_hu.

Similar Threads

  1. PED and signing.
    By IX in forum Symbian
    Replies: 11
    Last Post: 2008-04-21, 01:15
  2. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  3. Help needed with a 3gp file...
    By joedoe_1981 in forum Streaming and Video
    Replies: 0
    Last Post: 2007-07-18, 18:58
  4. could not find thread.mbg and thread.rsg
    By deercrane in forum Symbian
    Replies: 3
    Last Post: 2006-04-18, 09:44
  5. Series 60 SDK Appwizard on windows xp
    By moonjoor in forum Symbian Tools & SDKs
    Replies: 15
    Last Post: 2003-12-24, 10:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×