×

Discussion Board

Results 1 to 3 of 3

Thread: Gray image

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    27

    Gray image

    Hello *,

    here is my code: I load a colored image from a mbm file and want to display its grayscale, but it does not work, even when I set all points per hand (like TRgb(128,128,128).Value()), the a green pic is drawn.

    void CCamTimerFormView::GrayScale()
    {
    TBitmapUtil bitmapUtil(iContainer->iBitmap1);
    TInt iX = 0,iY = 0;
    TPoint pos(iX, iY);
    TInt cVal;
    TUint32 image_pixel;

    TSize BmpSize =iContainer->iBitmap1->SizeInPixels();

    bitmapUtil.Begin(TPoint(0, 0));

    for (iY = 0; iY < BmpSize.iHeight; iY++) {
    bitmapUtil.SetPos(TPoint(0,iY));
    for (iX = 0; iX<BmpSize.iWidth; iX++){

    image_pixel= bitmapUtil.GetPixel();
    TRgb* rgb = new TRgb(image_pixel);

    TInt gray = rgb->Gray256();

    bitmapUtil.SetPixel(TRgb(gray,gray,gray).Value());
    bitmapUtil.IncXPos();

    delete rgb;
    }
    }

    bitmapUtil.End();
    iContainer->DrawNow();
    }

    Can anybody help me?
    Thanks a lot.

    Manu

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    27
    I give a new hint, perhaps then somebody can help me.

    START BITMAP bild.mbm
    HEADER
    TARGETPATH ..\..\..\..\wins\c\system\apps\camtimer
    SOURCEPATH ..\bitmaps
    SOURCE c12 bmp1.bmp
    END

    and if I debug my source with a white image, than the blue value is 0, and not 255. Perhaps I have to set a different c-value, but I don`t understand how that really works.

    Manu

  3. #3
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    162
    Hi Manu,
    the use of your method rgb->Gray256() is for converting a grayscale-value into a rgb-value. Besides the return-value of that method is a RGB-type, but not a TInt-type.
    To my mind the getting of the gray-value isn't that good idea, because you will also receive an 32-bit-value, but you want to get a lower-value (TInt8?).
    So my suggestion is to get every single value of rgb (Red(), Green(), Blue()) and getting the maximum (value in the hsv-model). I think, that would be a good value for processing. You only have to convert a TInt32 into a TInt8.
    And please read my e-mails!!

    greetings Christian

Posting Permissions

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