How to display an image stored in the C: drive of the mobile on the screen?

Login to reply to this topic.
Thu, 2008-01-10 11:49
Joined: 2007-07-31
Forum posts: 152

Hi everybody,

I have a problem please help me in solving it...

(1).First i received the responce buffer (iResponceBuffer) from the server in HTTP communication.And written it in a file which is created in FileStream mode and whose extension is .bmp .The URL of the file stored on the server is "http://192.168.1.113/admin/brajesh/image3.bmp" and i written into the c:\ of the emulator .Code for this is given below.

void CHTTPExampleEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
        {
        switch (aEvent.iStatus)
                {
                case THTTPEvent::EGotResponseHeaders:
                       
                        break;


                case THTTPEvent::EGotResponseBodyData:
                        {
                        // Get text of response body
                        MHTTPDataSupplier* dataSupplier = aTransaction.Response().Body();
                        TPtrC8 ptr;
                        dataSupplier->GetNextDataPart(ptr);

                        // Convert to 16-bit descriptor
                        HBufC* buf = HBufC::NewLC(ptr.Length());
                        buf->Des().Copy(ptr);

                        // Append to iResponseBuffer
                        if (!iResponseBuffer)
                                {
                                iResponseBuffer = buf->AllocL();
                                }
                        else
                                {
                                iResponseBuffer = iResponseBuffer->ReAllocL(iResponseBuffer->Length() + buf->Length());
                                iResponseBuffer->Des().Append(*buf);
                                }
                               
                                //nn: Here the data is content in a 16 bit descriptor
                                // want to write it to a file or play it.

                        // Release buf
                        if (iResponseBuffer->Length()>=40960)
                        {
                        // to chk the progerss of program
                         /*CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
                    informationNote->ExecuteLD(_L("OK"));
                    delete informationNote;*/
                        //        iObserver.ResponseReceivedL(*iResponseBuffer);
                        //        iResponseBuffer=NULL;
                               
                               
                               
                        }
                        pFile->WriteToFile(*iResponseBuffer);
                        CleanupStack::PopAndDestroy(buf);

                        // Release the body data
                        dataSupplier->ReleaseData();
                       
                        //nm:  Pass the response buffer by reference to the observer
                        //iObserver.ResponseReceivedL(*iResponseBuffer);
                        }
                        break;

                case THTTPEvent::EResponseComplete:
                       
                        break;
                }
        }

void RFileHandler::WriteToFile(const TDesC& text)
{
        TInt CurrentPos,pos=0;
        CurrentPos = file.Seek(ESeekEnd,pos);       
        TPtrC8 representation((TUint8*)(&text)->Ptr(), (&text)->Size());
        User::LeaveIfError(file.Write(pos,representation)); // write text
        // Commit the data
        User::LeaveIfError(file.Flush());
}

Now problem is that when i open the stored bmp file, it shows the size of 4MB but shows preview is not available.

what is the problem????????

Please help me.....

I shall be very thank full to you....

Brajesh...


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++


Thu, 2008-01-10 13:10
Joined: 2004-11-29
Forum posts: 1197
Re: How to display an image stored in the C: drive of the mobile

Why do you convert your 8 bit descriptor to a 16 bit one, and then back to an 8 bit one again?

When you do "Copy", it will expand each 8 bit value in the source descriptor to a 16 bit value.
Then in the file write function, you access the memory of the 16 bit descriptor directly as an 8 bit descriptor...
Probably this is your problem, if you look in the file in a hex editor, probably every second byte in your file is "0x00", meaning you have trashed the contents.

There is no reason at all for you to convert it to a 16 bit descriptor and back again, keep it as an 8 bit all the way through.

  • Login to reply to this topic.