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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Gdiplus and Jpeg save

Gdiplus and Jpeg save

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsdata-structures
2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How can I save a window with graphical paints to a jpeg file???? See the code below: ///////////////////////////////////////////////////////////////////////////////// //gdiplus //////////////////////////////////////////////////////////////////////// int GetCodecClsid(const WCHAR* format, CLSID* pClsid){ UINT j,num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo * pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if(size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo *)(malloc(size)); if(pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(j=0; jtexto,pDoc->texto.GetLength()); arquivo.Close(); CPaintDC dc(this); // device context for painting using namespace Gdiplus; Graphics graphics(dc.m_hDC); Pen blue (Color(255, 0, 0, 255)); Pen red (Color(255, 255, 0, 0)); int y = 256; for (int x = 0; x < 256; x += 5){ graphics.DrawLine(&blue, 0, y, x, 0); graphics.DrawLine(&red, 256, x, y, 256); y -= 5; } for (y = 0; y < 256; y++){ Pen pen(Color(y, 0, 255,0)); graphics.DrawLine(&pen, 0, y, 256, y); Sleep(20); } for (x = 0; x < 256; x++){ Pen pen(Color(x, 255, 0, 255)); graphics.DrawLine(&pen, x, 100, x, 200); Sleep(20); } // Write window ----> Image Im(L"fig.gif", FALSE); // :) CLSID GifCodec; GetCodecClsid(L"image/jpeg", &GifCodec); Im.Save(L"gif.jpg", &GifCodec, NULL); }

    J 1 Reply Last reply
    0
    • L Lost User

      How can I save a window with graphical paints to a jpeg file???? See the code below: ///////////////////////////////////////////////////////////////////////////////// //gdiplus //////////////////////////////////////////////////////////////////////// int GetCodecClsid(const WCHAR* format, CLSID* pClsid){ UINT j,num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo * pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if(size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo *)(malloc(size)); if(pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(j=0; jtexto,pDoc->texto.GetLength()); arquivo.Close(); CPaintDC dc(this); // device context for painting using namespace Gdiplus; Graphics graphics(dc.m_hDC); Pen blue (Color(255, 0, 0, 255)); Pen red (Color(255, 255, 0, 0)); int y = 256; for (int x = 0; x < 256; x += 5){ graphics.DrawLine(&blue, 0, y, x, 0); graphics.DrawLine(&red, 256, x, y, 256); y -= 5; } for (y = 0; y < 256; y++){ Pen pen(Color(y, 0, 255,0)); graphics.DrawLine(&pen, 0, y, 256, y); Sleep(20); } for (x = 0; x < 256; x++){ Pen pen(Color(x, 255, 0, 255)); graphics.DrawLine(&pen, x, 100, x, 200); Sleep(20); } // Write window ----> Image Im(L"fig.gif", FALSE); // :) CLSID GifCodec; GetCodecClsid(L"image/jpeg", &GifCodec); Im.Save(L"gif.jpg", &GifCodec, NULL); }

      J Offline
      J Offline
      jfugate
      wrote on last edited by
      #2

      I use OpenIL for all my image reading and writing. OpenIL supports writing .jpgs and .gifs (and many other formats), though it really helps to be familiar with some OpenGL since OpenIL is sturctured very similarly. There are quite a few image libraries out there that can handle what you want, so you shouldn't have to reinvent the wheel.

      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