×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    27

    Why myBitmap-GetPixel() crashes sometimes?

    Dear *;

    I have a difficult problem:

    I tried to use the methode:
    GetPixel(), but it crashs, when I use it, here my is code:

    In the header-file:
    CFbsBitmap* myBitmap;

    I load my image fro the mbm-file:
    myBitmap = NBitmapMethods::CreateBitmapL(KMBMFileName,EMbmBildBmp1);

    using the class bitmapmethods (Is there an other possibility?)

    and the I try a loop, that gives me the color of the pixel:

    TInt iX = 0,iY = 0;
    TRgb* aColor;
    TSize BmpSize = myBitmap->SizeInPixels();

    for (iY = 0; iY < BmpSize.iHeight; iY++) {
    for (iX = 0; iX < BmpSize.iWidth; iX++) { myBitmap->GetPixel(*aColor, TPoint(iY,iX));
    }
    }

    But it crashs in the emulator on the GetPixel()-position

    Does anybody know why?

    Thank you very much
    Manu

  2. #2
    Regular Contributor
    Join Date
    Oct 2004
    Posts
    53

    Re: Why myBitmap-GetPixel() crashes sometimes?

    Originally posted by manu.20
    ...TPoint(iY,iX));...
    Because you've put iY & iX the wrong way round.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    27
    Thank you very much for your help greatape!

    But I think this is not the problem, because it crashes in the first loop and there iX and iY are 0. It even crashs, when I write:
    MyBitmap->GetPixel(*aColor, TPoint(5,5));

    The error is an untreated exception in epoc.exe (FBSCLI.DLL).

    Can plz tell me anybody, why?

  4. #4
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    Hi Manu,
    I really enjoy to answer your postings...
    There's only one line missing in your code:

    TBitmapUtil bitmapUtil(yourBitmap);

    Yeah!
    So you have an handle on your bitmap (previous to your loop). Even if you don't use the methods of this handle, you have to take it.
    But maybe we can talk about it by lunch?

    Best regards
    Christian

  5. #5
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89
    I cannot have lunch with you guys, but can you please say a few words in what situations taking handle is necessary? This is very interesting, I didn't care to do it so far, but my bitmap operations are very limited.

  6. #6
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    Hi Marat,
    when you want to handle a bitmap it's important to have this handle on the bitmap. Without it you have no access (fortunately).
    Christian

  7. #7
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89
    Thank you chrishawaii, but what exactly do you mean by "handling" the bitmap? I was able to draw on the bitmap, draw the bitmap, use methods like ScanLineLength, GetScanLine, SetScanLine of the bitmap, and even feed bitmaps to CImageDecoder without getting any handles, although I've heard with handles something might be faster. I didn't try to get separate pixels though.

    What devices require getting a handle? I'm using Series 60 Nokias like 6600 and 6630.

  8. #8
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    She (Manu) tried to use the GetPixel method without having a TBitmapUtil bitmapUtil(CameraBitmap); on her bitmap.
    That doesn't work.
    You better asked me, why the GetPixel()-method of the class TBitmapUtil doesn't give the right pixel-value, although all other methods work fine. Otherwise this class would be very convenient to use.
    I don't know.

  9. #9
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    89
    Ok, I understood that I should not worry about my methods, thank you. BTW who needs GetPixel anyway, I expect it to be orders slower than GetScanLine.

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    1

    Re: Why myBitmap-GetPixel() crashes sometimes?

    You are passing a reference to undefined (unallocated TRgb).

    Maybe you try changing:

    TRgb* aColor;

    and GetPixel(*aColor ..

    to

    TRgb aColor;
    GetPixel(aColor, ...

    Good luck,

    -arne

  11. #11
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162

    Re: Why myBitmap-GetPixel() crashes sometimes?

    hi arne,
    why do you prefer this way? what is the advantage in disclaiming pointer?
    did you try this way? did you disclaim the handle on the bitmap:
    TBitmapUtil bitmapUtil(yourBitmap); ???
    That would be interesting. does your way really work?

    chris

Posting Permissions

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