C++如何实现设置某张图片全屏显示,并且仅显示这张图片

andong133 2014-04-17 11:00:24
C++如何实现设置某张图片全屏显示,并且仅显示这张图片。
即:
这张图片覆盖了桌面上所有图标和当前其他的软件窗口。
非常感谢大家啊!
...全文
1628 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
you can display the image with opencv ,plz. for examples: int main() { Mat image = imread("DSC02645.JPG"); namedWindow("pic_viewer", CV_WINDOW_NORMAL); setWindowProperty("pic_viewer", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); imshow("pic_viewer", image); waitKey(1000); //每隔1秒显示 }
Magic旭 2014-08-04
  • 打赏
  • 举报
回复
可以先将这个窗口设置成无边框的、最大化的,并且置顶,再将图片用StrechBlt画到窗口上。
赵4老师 2014-07-09
  • 打赏
  • 举报
回复
palm_m 2014-07-09
  • 打赏
  • 举报
回复
引用 3 楼 zhao4zhong1 的回复:
StretchBlt The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. BOOL StretchBlt( HDC hdcDest, // handle to destination device context int nXOriginDest, // x-coordinate of upper-left corner of dest. rectangle int nYOriginDest, // y-coordinate of upper-left corner of dest. rectangle int nWidthDest, // width of destination rectangle int nHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source device context int nXOriginSrc, // x-coordinate of upper-left corner of source rectangle int nYOriginSrc, // y-coordinate of upper-left corner of source rectangle int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle DWORD dwRop // raster operation code ); Parameters hdcDest Handle to the destination device context. nXOriginDest Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle. nYOriginDest Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle. nWidthDest Specifies the width, in logical units, of the destination rectangle. nHeightDest Specifies the height, in logical units, of the destination rectangle. hdcSrc Handle to the source device context. nXOriginSrc Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. nYOriginSrc Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. nWidthSrc Specifies the width, in logical units, of the source rectangle. nHeightSrc Specifies the height, in logical units, of the source rectangle. dwRop Specifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap. See BitBlt for a list of common raster operation codes. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT: To get extended error information, callGetLastError. Remarks StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. The color data for pattern or destination pixels is merged after the stretching or compression occurs. When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context. If the specified raster operation requires a brush, the system uses the brush currently selected into the destination device context. The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context. If the source transformation has a rotation or shear, an error occurs. If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmap. If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert a color bitmap to a monochrome bitmap, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used. StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest parameters or of the nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis. Not all devices support the StretchBlt function. For more information, see the GetDeviceCaps. ICM: No color management is performed when a blit operation occurs. Windows CE: Windows CE version 1.0 supports only the SRCCOPY and SRCINVERT raster operations. Windows CE version 1.0 does not support mirroring. This function is the same in Windows CE version 2.0 as it is in Windows desktop platforms. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in wingdi.h. Import Library: Use gdi32.lib. See Also Bitmaps Overview, Bitmap Functions, BitBlt, GetDeviceCaps, MaskBlt, PlgBlt, SetStretchBltMode 参考MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\SHOWDIB\*.*
赵老师,感觉你那里例子代码很多呀,压个包,放共享里让我们下载下载吧
赵4老师 2014-07-09
  • 打赏
  • 举报
回复
引用 5 楼 palm_m 的回复:
[quote=引用 3 楼 zhao4zhong1 的回复:] StretchBlt The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. BOOL StretchBlt( HDC hdcDest, // handle to destination device context int nXOriginDest, // x-coordinate of upper-left corner of dest. rectangle int nYOriginDest, // y-coordinate of upper-left corner of dest. rectangle int nWidthDest, // width of destination rectangle int nHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source device context int nXOriginSrc, // x-coordinate of upper-left corner of source rectangle int nYOriginSrc, // y-coordinate of upper-left corner of source rectangle int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle DWORD dwRop // raster operation code ); Parameters hdcDest Handle to the destination device context. nXOriginDest Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle. nYOriginDest Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle. nWidthDest Specifies the width, in logical units, of the destination rectangle. nHeightDest Specifies the height, in logical units, of the destination rectangle. hdcSrc Handle to the source device context. nXOriginSrc Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. nYOriginSrc Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. nWidthSrc Specifies the width, in logical units, of the source rectangle. nHeightSrc Specifies the height, in logical units, of the source rectangle. dwRop Specifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap. See BitBlt for a list of common raster operation codes. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT: To get extended error information, callGetLastError. Remarks StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. The color data for pattern or destination pixels is merged after the stretching or compression occurs. When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context. If the specified raster operation requires a brush, the system uses the brush currently selected into the destination device context. The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context. If the source transformation has a rotation or shear, an error occurs. If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmap. If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert a color bitmap to a monochrome bitmap, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used. StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest parameters or of the nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis. Not all devices support the StretchBlt function. For more information, see the GetDeviceCaps. ICM: No color management is performed when a blit operation occurs. Windows CE: Windows CE version 1.0 supports only the SRCCOPY and SRCINVERT raster operations. Windows CE version 1.0 does not support mirroring. This function is the same in Windows CE version 2.0 as it is in Windows desktop platforms. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in wingdi.h. Import Library: Use gdi32.lib. See Also Bitmaps Overview, Bitmap Functions, BitBlt, GetDeviceCaps, MaskBlt, PlgBlt, SetStretchBltMode 参考MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\SHOWDIB\*.*
赵老师,感觉你那里例子代码很多呀,压个包,放共享里让我们下载下载吧[/quote] 可以先下载我的资源里面的源代码。
狂奔的Ant 2014-07-03
  • 打赏
  • 举报
回复
赵老师依旧这么霸气
赵4老师 2014-04-17
  • 打赏
  • 举报
回复
仅供参考
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    PAINTSTRUCT ps;
    HDC hdc;
    HFONT hfont,ohfont;
    RECT r;
    COLORREF oc;

    switch(message) {
    case WM_CLOSE://按Alt+F4退出
        PostQuitMessage(0);
        break;
    case WM_PAINT:
        BeginPaint(hWnd, &ps);
        hdc = ps.hdc; // the device context to draw in
        GetClientRect(hWnd, &r); // Obtain the window's client rectangle
        hfont = CreateFont(240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "华文楷体");
        ohfont=SelectObject(hdc,hfont);
        oc=SetTextColor(hdc,0x00C080FF);
        SetBkMode(hdc, TRANSPARENT);
        TextOut(hdc,r.left+r.right/2-720, r.top+r.bottom/2-120,"最短画图程序",12);
        SelectObject(hdc,ohfont);
        SetTextColor(hdc,oc);
        DeleteObject(hfont);
        EndPaint(hWnd, &ps);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    MSG msg             = {0};
    WNDCLASS wc         = {0};
    HBRUSH hbrh;
    hbrh=CreateSolidBrush(0x00000000);
    wc.lpfnWndProc      = WndProc;
    wc.hInstance        = hInstance;
    wc.hbrBackground    = hbrh;
    wc.lpszClassName    = "minwindowsapp";
    wc.hCursor          = LoadCursor(NULL,IDC_ARROW);
    if( FAILED(RegisterClass(&wc)) ) return 1;

    if(FAILED(CreateWindow(wc.lpszClassName,
                        "Minimal Windows Application",
                        WS_POPUP|WS_VISIBLE,
                        0,
                        0,
                        GetSystemMetrics(SM_CXSCREEN),
                        GetSystemMetrics(SM_CYSCREEN),
                        0,
                        0,
                        hInstance,
                        NULL)))
        return 2;

    while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) {
        DispatchMessage( &msg );
    }
    DeleteObject(hbrh);
    return 0;
}
赵4老师 2014-04-17
  • 打赏
  • 举报
回复
StretchBlt The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. BOOL StretchBlt( HDC hdcDest, // handle to destination device context int nXOriginDest, // x-coordinate of upper-left corner of dest. rectangle int nYOriginDest, // y-coordinate of upper-left corner of dest. rectangle int nWidthDest, // width of destination rectangle int nHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source device context int nXOriginSrc, // x-coordinate of upper-left corner of source rectangle int nYOriginSrc, // y-coordinate of upper-left corner of source rectangle int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle DWORD dwRop // raster operation code ); Parameters hdcDest Handle to the destination device context. nXOriginDest Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle. nYOriginDest Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle. nWidthDest Specifies the width, in logical units, of the destination rectangle. nHeightDest Specifies the height, in logical units, of the destination rectangle. hdcSrc Handle to the source device context. nXOriginSrc Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle. nYOriginSrc Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle. nWidthSrc Specifies the width, in logical units, of the source rectangle. nHeightSrc Specifies the height, in logical units, of the source rectangle. dwRop Specifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap. See BitBlt for a list of common raster operation codes. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Windows NT: To get extended error information, callGetLastError. Remarks StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. The color data for pattern or destination pixels is merged after the stretching or compression occurs. When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context. If the specified raster operation requires a brush, the system uses the brush currently selected into the destination device context. The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context. If the source transformation has a rotation or shear, an error occurs. If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmap. If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert a color bitmap to a monochrome bitmap, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used. StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest parameters or of the nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis. Not all devices support the StretchBlt function. For more information, see the GetDeviceCaps. ICM: No color management is performed when a blit operation occurs. Windows CE: Windows CE version 1.0 supports only the SRCCOPY and SRCINVERT raster operations. Windows CE version 1.0 does not support mirroring. This function is the same in Windows CE version 2.0 as it is in Windows desktop platforms. QuickInfo Windows NT: Requires version 3.1 or later. Windows: Requires Windows 95 or later. Windows CE: Requires version 1.0 or later. Header: Declared in wingdi.h. Import Library: Use gdi32.lib. See Also Bitmaps Overview, Bitmap Functions, BitBlt, GetDeviceCaps, MaskBlt, PlgBlt, SetStretchBltMode 参考MSDN98\SAMPLES\VC98\SDK\GRAPHICS\GDI\SHOWDIB\*.*
andong133 2014-04-17
  • 打赏
  • 举报
回复
[quote=引用 1 楼 zhao4zhong1 的回复:] 仅供参考[code=c]#include <windows.h> 有没有一个简单的API函数啊?主要目的就是全屏显示一张图片。谢谢你了

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧