×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    CFbsBitmap Save doesn't save a proper bitmap

    Hello,
    I just wanted to try the bitmap saving routine, but it seems it does not work for me

    i make something like this:
    act_img = new (ELeave)CFbsBitmap;
    act_img->Create(TSize(aFrameW,aFrameH),EColor16MU);

    then i copy pixel data to it and try to save with:
    act_img->Save((*fname.AnsiStringToHBufLC()));
    The files are saved but i can't open it with any viewer (and even the filesize is quite wrong should be about 1,2 MB [it has 871 kb] (for 640x480x32 bpp image),
    now i don't know but maybe the header has different structure than native windows bitmap format or what.


    And other strange thing that i cant save bitmap from a thread (it crashes when Save is called)
    I made sure not to use act_img while saving it to file. (the var FrameFlush is there)

    if (RequestThreadToSaveBitmap == true) {
    RequestThreadToSaveBitmap = false;
    SNAPSHOTAKEN = true;
    FrameFlush = true;
    globalcount = globalcount + 1;
    AnsiString fname;
    fname = "E:\\Temp\\Image";
    fname = fname + IntToStr(globalcount);
    fname = fname + ".bmp";
    act_img->Save((*fname.AnsiStringToHBufLC()));
    FrameFlush = false;
    }
    I am sure its the save that crashes (in thread because i tried also
    _LIT(f,"E:\\Temp\\sample.bmp");
    act_img->Save(f);
    and it still crashes


    cheers
    Last edited by melepeta; 2013-11-13 at 19:55.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: CFbsBitmap Save doesn't save a proper bitmap

    it saves symbian bitmap image, and indeed its not bmp. So you would actually need to use real image encoders for saving it in a format which could be used in other platforms.

    Here's example for the task: http://developer.nokia.com/Community...mages_to_files

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: CFbsBitmap Save doesn't save a proper bitmap

    Thank you yucca, however i am wondering if i could speedup the write process and make my own bitmap, i just need to wrtie 'blocks' (in c++ its the BlockWrite function)
    Is there any symbian equivalent function for this? You know open file stream write to this stream and close it ;]

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: CFbsBitmap Save doesn't save a proper bitmap

    I don't think you could do it any faster really, though RFile indeed does allow you to write binary data, thus if you are targeting 256 color bmp, and you would be skipping the header parts, then I suppose it would be really easy to form the bmp in HBufC8 variable, and use it for writing. Then only thing you would need to do is to get pixels from the image and save them accordingly to the byte in the buffer..

    Anyway, I'm rather sure you get acceptable speed with the real API, as well as there is less logic to design & test, thus the development effort for using the real API would definitely be less.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,696

    Re: CFbsBitmap Save doesn't save a proper bitmap

    If you do not want to fight with active objects, a thing what you can use is the EOptionAlwaysThread flag. Then you can simply User::WaitForRequest for completion.
    See http://developer.nokia.com/Community...ymbian_C%2B%2B

  6. #6
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: CFbsBitmap Save doesn't save a proper bitmap

    i have followed yucca sample:
    http://developer.nokia.com/Community...mages_to_files


    But since i think it won't be async (because class is created and then image is saved) i tried to change the code that CjpgSaver class will save image in RunL() function.

    After writing new ActiveObject class and trying to build it i get:
    ..\..\..\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\Carbide\MobEye\group\MOBEYE\GCCE\UREL\JpgSaver.o: In function `CJpgSaver::RunL()':
    Jpgsaver.cpp.text+0x4a0): undefined reference to `CImageEncoder::FileNewL(RFs&, TDesC16 const&, TDesC8 const&, CImageEncoder::TOptions)'
    Jpgsaver.cpp.text+0x4c8): undefined reference to `CImageEncoder::Convert(TRequestStatus*, CFbsBitmap const&, CFrameImageData const*)'
    make[1]: *** [..\..\..\9.1\S60_3rd_MR\EPOC32\RELEASE\GCCE\UREL\MobEye.exe] Error 1


    shouldn't func CJpgSaver::CJpgSaver(CFbsBitmap& aBitmap, TDesC& aFileName)
    :CActive(EPriorityStandard),iBitmap(aBitmap), iFileName(aFileName)
    initialize these references?


    header
    Code:
    #ifndef JPGSAVER_H
    #define JPGSAVER_H
    
    #include <e32base.h>	// For CActive, link against: euser.lib
    #include <e32std.h>		// For RTimer, link against: euser.lib
    #include <f32file.h>
    #include <gdi.h>
    #include <ImageConversion.h>
    #include <coemain.h>
    #include "stringunit.h"
    
    _LIT8(KMimeType,"image/jpeg");
    
    class CJpgSaver : public CActive
    	{
    public:
    	 CJpgSaver(CFbsBitmap& aBitmap,  TDesC& aFileName);
    	~CJpgSaver();
    
    	static CJpgSaver* NewL(CFbsBitmap& aBitmap, TDesC& aFileName);
    	static CJpgSaver* NewLC(CFbsBitmap& aBitmap, TDesC& aFileName);
    
    public:
    	void StartL(TTimeIntervalMicroSeconds32 aDelay);
    
    private:
        void ConstructL();
    
    	void RunL();
    
    	void DoCancel();
    
    	TInt RunError(TInt aError);
    
    private: enum TJpgSaverState {EUninitialized,EInitialized, EError};
    
    private:
    	TInt iState; 
    	RTimer iTimer; 
    
        CFbsBitmap& 		iBitmap;
        CImageEncoder* 		iEncoder;
        TDesC&                                iFileName;
    
    	};
    
    #endif // JPGSAVER_H

    source
    Code:
    #include "JpgSaver.h"
    
    
    CJpgSaver::CJpgSaver(CFbsBitmap& aBitmap, TDesC& aFileName)
    :CActive(EPriorityStandard),iBitmap(aBitmap), iFileName(aFileName)   
    	{
    
    	}
    
    CJpgSaver* CJpgSaver::NewLC(CFbsBitmap& aBitmap, TDesC& aFileName)
    	{
    	CJpgSaver* self = new (ELeave) CJpgSaver(aBitmap, aFileName);
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    	}
    
    CJpgSaver* CJpgSaver::NewL(CFbsBitmap& aBitmap, TDesC& aFileName)
    	{
    	CJpgSaver* self = CJpgSaver::NewLC(aBitmap, aFileName);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CJpgSaver::ConstructL()
    	{
    	User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
    	CActiveScheduler::Add(this); // Add to scheduler
    	}
    
    CJpgSaver::~CJpgSaver()
    	{
    	Cancel(); // Cancel any request, if outstanding
    	iTimer.Close(); // Destroy the RTimer object
    	delete iEncoder;  
    	}
    
    void CJpgSaver::DoCancel()
    	{
    	Cancel();
    	iTimer.Cancel();
    	}
    
    void CJpgSaver::StartL(TTimeIntervalMicroSeconds32 aDelay)
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iState = EUninitialized;
    	iTimer.After(iStatus, aDelay); // Set for later
    	SetActive(); // Tell scheduler a request is active
    	}
    
    void CJpgSaver::RunL()
    	{
    
        iEncoder = CImageEncoder::FileNewL(CCoeEnv::Static()->FsSession(),iFileName, KMimeType);
        iEncoder->Convert( &iStatus, iBitmap);
        DoCancel();
        delete this;
    	}
    
    TInt CJpgSaver::RunError(TInt aError)
    	{
    	return aError;
    	}
    Last edited by melepeta; 2013-11-16 at 21:28.

  7. #7
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: CFbsBitmap Save doesn't save a proper bitmap

    those errors simply indicate that the implementation for the class is not found, thus add the imageconversion.lib inclusion into your mmp file and try again.

  8. #8
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: CFbsBitmap Save doesn't save a proper bitmap

    Yes, that was it. Thank you.

Similar Threads

  1. Save CFbsBitmap to File
    By skela in forum Streaming and Video
    Replies: 14
    Last Post: 2010-03-26, 09:24
  2. how can I save a scaled bitmap ??
    By chandu.arigela in forum Symbian
    Replies: 12
    Last Post: 2009-02-16, 09:05
  3. save bitmap to ota
    By khemarak_168 in forum Symbian
    Replies: 2
    Last Post: 2007-01-13, 03:02

Posting Permissions

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