Results 1 to 7 of 7

Thread: Drawing picture with different RGB

  1. #1

    Drawing picture with different RGB

    Hello.

    I got picture, where pixels are "white"
    http://pp.kpnet.fi/kmje/ukko.gif

    And here, how I'd like to get it drawed.
    http://www.netsoccer.biz/screenshot1.gif

    So I'd like to get original image drawed with different RGB's
    Is there some function in SDL or how it should be done?
    www.netsoccer.biz

  2. #2

    Drawing picture with different RGB

    sure you can, take a look at the game Catapults I made especially at ColorizeImage.

    [pascal]procedure ColorizeImage(var srcImage, destImage: PSDL_Surface;
    srcRect, maskRect: TSDL_Rect; Color: UInt32);
    var
    ObjectOverLayColour, TempImage : PSDL_Surface;
    begin
    {the remark area is unnecessary IF you select you image carefully}
    // Create a surface to hold the negative colour to be subtracted.
    ObjectOverLayColour := SDL_CreateRGBSurface( SDL_SWSURFACE, destImage.w, destImage.h,
    Screen.format.BitsPerPixel, Screen.format.RMask, Screen.format.GMask,
    Screen.format.BMask, Screen.format.AMask );
    // Create a temporary working surface.
    TempImage := SDL_CreateRGBSurface( SDL_SWSURFACE, destImage.w, destImage.h,
    Screen.format.BitsPerPixel, Screen.format.RMask, Screen.format.GMask,
    Screen.format.BMask, Screen.format.AMask );
    // Make sure that the temp image uses pink as the transparent colour
    // SDL_SetColorKey( TempImage, SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL,
    // 0{SDL_MapRGB( ObjectOverLayColour.format, 255, 0, 255 )} );

    // Copy the sprite image to our work area
    SDL_BlitSurface( srcImage, @srcRect, TempImage, nil);
    // SDL_SaveBMP(TempImage, '1.bmp');

    // Fill the Colour surface with the appropritate colour
    SDL_FillRect( ObjectOverLayColour , nil, Color);
    // SDL_SaveBMP(ObjectOverLayColour, '2.bmp');
    // Subtract the colour from the work surface
    SDL_SubSurface( ObjectOverLayColour, nil, TempImage, nil );
    // SDL_SaveBMP(TempImage, '3.bmp');
    // Blit our Mask onto the work area. This gets around the colour problem
    // SDL_BlitSurface( srcImage, @maskRect, TempImage, nil);

    // Make sure that the Image uses pink as the transparent colour
    // SDL_SetColorKey( destImage, SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL,
    // SDL_MapRGB( destImage.format, 255, 0, 255 ) );
    // Blit the work surface to the Image
    // SDL_SetColorKey( TempImage, SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL,
    // 0 );
    SDL_BlitSurface( TempImage, nil, destImage, nil );
    // SDL_BlitSurface( srcImage, @maskRect, destImage, nil);
    SDL_SetColorKey( destImage, SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL, 0 );

    SDL_FreeSurface( TempImage );
    SDL_FreeSurface( ObjectOverLayColour );
    end;[/pascal]

    I see I have a lot of comments in there... you’ll have to play around with it, it should work as it is.
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  3. #3

    Drawing picture with different RGB

    Thanks.

    I downloaded catapults source and have been "exploring" it for hours, but source seems too confusing to me. :?

    Could you give small sample, how that it works?
    www.netsoccer.biz

  4. #4

    Drawing picture with different RGB

    I'm trying to use the above procedure to color my surfaces, but for some reason I'm getting an error with the 'AsciiMap.Format' part, when trying to set the transparency color of my surface:

    [pascal]VAR AsciiMap : PSDL_Surface;
    TempImage : PSDL_Surface;

    {...}

    TempImage := SDL_LoadBMP('640x400.bmp');
    AsciiMap := SDL_DisplayFormat(TempImage);
    SDL_SetColorKey(AsciiMap, SDL_SRCCOLORKEY OR SDL_RLEACCEL, SDL_MapRGB(AsciiMap.Format, 255, 0, 255));
    [/pascal]

    I can't figure out what I'm doing wrong. I believe I'm declaring the surfaces correctly.


    EDIT: The compile error I'm getting is 'Unexpected identifier "Format"', so it seems there's something wrong with my AsciiMap surface - maybe I haven't declared it correctly? Any help would be appreciated!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  5. #5

    Drawing picture with different RGB

    A correction: The compiler error message I'm getting is:

    Syntax error, ")" expected but "identifier FORMAT" found
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  6. #6

    Drawing picture with different RGB

    AsciiMap is a pointer (hence the "P"). So
    Code:
    AsciiMap^.format
    is what you want, actually.

  7. #7

    Drawing picture with different RGB

    Argh, of course! Such a simple mistake! Thanks!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

Bookmarks

Posting Permissions

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