Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to display a big JPEG picture with DirectDraw

How to display a big JPEG picture with DirectDraw

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinformsjsonperformancehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tal Rashas Guardianship
    wrote on last edited by
    #1

    Hi,there I'd like to load a JPEG picture onto a DirectDraw7 surface. For parsing the JPEG, I have used GDI+, the code like this: Bitmap bitmap(L"F:\\images\\CIMG1531_1.jpg"); g_width = bitmap.GetWidth(); g_height = bitmap.GetHeight(); //create surface, load image DDSURFACEDESC2 ddsd2; INIT_STRUCT(ddsd2); ddsd2.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; ddsd2.dwWidth = g_width; ddsd2.dwHeight = g_height; ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY; if(FAILED(g_lpdd7->CreateSurface(&ddsd2, &g_lpddsSecond, NULL))) return -1; HDC hDC; if(SUCCEEDED(g_lpddsSecond->GetDC(&hDC))) { Graphics graphics(hDC); graphics.DrawImage(&bitmap, 0, 0); g_lpddsSecond->ReleaseDC(hDC); } when the picture is small, the code works fine. otherwise, there's only a part of the picture could be display! The test picture has a resolution of 2990*2000, it's big, the problem occurs. when I change the code like this: ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY; to create the surface in system memory, the area displayed increased, but not all yet.

    M 1 Reply Last reply
    0
    • T Tal Rashas Guardianship

      Hi,there I'd like to load a JPEG picture onto a DirectDraw7 surface. For parsing the JPEG, I have used GDI+, the code like this: Bitmap bitmap(L"F:\\images\\CIMG1531_1.jpg"); g_width = bitmap.GetWidth(); g_height = bitmap.GetHeight(); //create surface, load image DDSURFACEDESC2 ddsd2; INIT_STRUCT(ddsd2); ddsd2.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT; ddsd2.dwWidth = g_width; ddsd2.dwHeight = g_height; ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY; if(FAILED(g_lpdd7->CreateSurface(&ddsd2, &g_lpddsSecond, NULL))) return -1; HDC hDC; if(SUCCEEDED(g_lpddsSecond->GetDC(&hDC))) { Graphics graphics(hDC); graphics.DrawImage(&bitmap, 0, 0); g_lpddsSecond->ReleaseDC(hDC); } when the picture is small, the code works fine. otherwise, there's only a part of the picture could be display! The test picture has a resolution of 2990*2000, it's big, the problem occurs. when I change the code like this: ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY; to create the surface in system memory, the area displayed increased, but not all yet.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      How are you displaying it once you've drawn it on the surface? What video mode?

      T 1 Reply Last reply
      0
      • M Mark Salsbery

        How are you displaying it once you've drawn it on the surface? What video mode?

        T Offline
        T Offline
        Tal Rashas Guardianship
        wrote on last edited by
        #3

        this is the drawing code: RECT dest, src; dest.left = pt.x+100; dest.top = pt.y+50; dest.right = pt.x + 400; dest.bottom = pt.y + 350; src.left = 0; src.top = 0; src.right = g_width-1; src.bottom = g_height-1; g_lpddsPrimary->Blt(&dest, g_lpddsSecond, &src, DDBLT_WAIT, NULL); g_lpddsPrimary is the primary surface video mode?sorry I don't know what you mean

        M 1 Reply Last reply
        0
        • T Tal Rashas Guardianship

          this is the drawing code: RECT dest, src; dest.left = pt.x+100; dest.top = pt.y+50; dest.right = pt.x + 400; dest.bottom = pt.y + 350; src.left = 0; src.top = 0; src.right = g_width-1; src.bottom = g_height-1; g_lpddsPrimary->Blt(&dest, g_lpddsSecond, &src, DDBLT_WAIT, NULL); g_lpddsPrimary is the primary surface video mode?sorry I don't know what you mean

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          giant_hao wrote:

          video mode?sorry I don't know what you mean

          I meant display mode. I asked just in case you were trying to draw 2990x2000 image on 1280x1024 display without stretching. I would think your code should work. Perhaps Creating Wide Surfaces[^] is an issue since you are creating an offscreen surface larger than the primary..(?) Also what happens if you try this (keep the aspect ratio of the src image)... RECT dest, src; dest.left = pt.x+100; dest.top = pt.y+50; dest.right = dest.left + (g_width / 10 - 1); dest.bottom = dest.top + (g_height / 10 - 1); src.left = 0; src.top = 0; src.right = g_width-1; src.bottom = g_height-1; g_lpddsPrimary->Blt(&dest, g_lpddsSecond, &src, DDBLT_WAIT, NULL);

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups