游戏开发论坛

 找回密码
 立即注册
搜索
查看: 4567|回复: 0

Directx9, 加载表面,显示,png图片,透明色变成了黑色。

[复制链接]

2

主题

2

帖子

20

积分

注册会员

Rank: 2

积分
20
发表于 2016-12-1 12:57:43 | 显示全部楼层 |阅读模式

1,
//create surface
    result = d3ddev->CreateOffscreenPlainSurface(
        info.Width,         //width of the surface
        info.Height,        //height of the surface
        D3DFMT_X8R8G8B8,    //surface format
        D3DPOOL_DEFAULT,    //memory pool to use
        &surTest2,             //pointer to the surface
        NULL);              //reserved (always NULL)

    if (result != D3D_OK) return NULL;

    //load surface from file into newly created surface
    result = D3DXLoadSurfaceFromFile(
        image,                  //destination surface
        NULL,                   //destination palette
        NULL,                   //destination rectangle
        filename.c_str(),       //source filename
        NULL,                   //source rectangle
        D3DX_DEFAULT,           //controls how image is filtered
        D3DCOLOR_XRGB(0,0,0),   //for transparency (0 for none)
        NULL);                  //source image info (usually NULL)


2,使用
d3ddev->StretchRect(surTest2, NULL, backbuffer, &rc, D3DTEXF_LINEAR);
显示出来..

结果已经显示出来了。但是有两个问题。
a,原来的图片是1.png,这个png是有透明色的。结果透明色变成了黑色。
b , 图片边缘不对了。。。。。

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-4-18 22:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表