Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: How store TDirectDrawSurface to TDIB ?

  1. #11

    How store TDirectDrawSurface to TDIB ?

    Where is error? What is wrong ? :cry:

    My simulation is here :

    [pascal]var ddck:TDDColorKey; TranspCol :Integer;
    ..
    if DXImageList1.Items.Find('picture1').PatternSurface s[0].ISurface.GetColorKey(DDCKEY_SRCBLT, ddck) = DD_OK then
    TranspCol := ddck.dwColorSpaceLowValue;[/pascal]

    On picture is really set transparent color clLime $00FF00.

    But TranspCol contain stupid color $7E0 :shock:

    Why, please?
    Ijcro.

  2. #12

    How store TDirectDrawSurface to TDIB ?

    What bit-depth is your surface using?
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  3. #13

    How store TDirectDrawSurface to TDIB ?

    Using 16b as standard (for tests 32 b too).

    EDIT:
    Have to I convert color and how?
    Ijcro.

  4. #14

    How store TDirectDrawSurface to TDIB ?

    :? [pascal]//------------------------------------------------------------------------------
    // ColourTo16BitRGB
    //
    // Convert a standard TColor to it's 16 bit RGB value
    //
    // BY Codetapper and Czar
    //------------------------------------------------------------------------------
    function ColourTo16BitRGB(InitialCol: TColor): Cardinal;
    var aRed, aGreen, aBlue, sRed, sGreen, sBlue: integer;
    begin
    sRed := InitialCol and $ff;
    sGreen := (InitialCol shr and $ff;
    sBlue := (InitialCol shr 16) and $ff;

    aRed := (32 * sRed) div 256;
    aGreen := (64 * sGreen) div 256;
    aBlue := (32 * sBlue) div 256;

    Result := (aRed shl 11) + (aGreen shl 5) + (aBlue shl 0);
    end;[/pascal]

    I figured I would post this reply here. We too had problems with the 16 bit colour depth. In order to be able to draw on the surface we decided it was easier to convert TColor to 16bit colour using the code above.
    The views expressed on this programme are bloody good ones. - Fred Dagg

  5. #15

    How store TDirectDrawSurface to TDIB ?

    My function

    [pascal]
    function LoadTextures(dds:TDirectDrawSurface;Transparent:Bo olean):Boolean;
    Var
    DIB: TDIB;
    ddck:TDDColorKey;
    COL:Integer;
    TEX: TDirect3DTexture2; {now as local, else as public}
    Begin
    Result := True;
    Try
    DIB := TDIB.Create;
    Try
    DIB.AsSign(dds); // picture here now
    DIB.Transparent := Transparent; //is transparent
    //FDDraw is TCustomDXDraw for me
    TEX := TDirect3DTexture2.Create(FDDraw, DIB, False); //create texture from DIB
    If dds.IDDSurface <> NIL Then //exists
    if dds.ISurface.GetColorKey(DDCKEY_SRCBLT,ddck) = DD_OK Then //get color
    COL := ddck.dwColorSpaceLowValue; //transparent color here
    Tex.Transparent := Transparent; //set up flag transparent
    Tex.TransparentColor := COL; //and main color
    //Problem when draw to 16 bit target surface only (but 32 bit is OK)
    //COL here is decreased as 16 bit but Tex is stil 32 bit
    //no match COL in TEX = ERROR, no transparency show
    Finally
    DIB.Free;
    End;
    Except
    Result := False;
    End;
    End;
    [/pascal]

    Problem in comment described.

    Very thanks for any answer.
    Ijcro.

Page 2 of 2 FirstFirst 12

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
  •