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. Help CxImage Drawing Problems!

Help CxImage Drawing Problems!

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsdebugging
1 Posts 1 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.
  • Z Offline
    Z Offline
    Zero_divide_1
    wrote on last edited by
    #1

    Hello all! I've racked my brains on this problem, and have now turned to those who know more than I for some solutions. I am creating an ISAPI Extension to generate GIF images and save them in my /images folder so that my site has immediate access to them. The reason I am using an ISAPI Extension is so that I can administer my website 100% via the web, but the site is heavily graphics dependent. I turned to the CxImage library for its support for saving GIF images, but I am having problems drawing. In a test program that I am using to test CxImage's functionality in this project, I am having some problems drawing. Here is a code sample: void CImageGeneratorDlg::OnButton1() { // TODO: Add your control notification handler code here CxIOFile ioFile; CString fileName; m_cEdit.GetWindowText(fileName); ioFile.Open(fileName, "wb"); CxImage* generatedImg = GenerateImage(); CxImage* images[] = { generatedImg }; //generatedImg->IncreaseBpp(24); generatedImg->DecreaseBpp(8,0,0); long idx = generatedImg->GetPixelIndex(0,0); generatedImg->SetTransIndex(idx); generatedImg->SetPaletteColor(idx+1, RGB(255,0,255)); CxImageGIF imageGIF; imageGIF.SetComment(_T("test")); imageGIF.Encode(&ioFile, images, 1); ioFile.Close(); } CxImage* CImageGeneratorDlg::GenerateImage() { CxImage* img = new CxImage(50,100,24); if(!img) { TRACE("==>Could not create image"); return NULL; } img->Clear(); CDC screenDC; if(!screenDC.CreateDC("DISPLAY", NULL, NULL, NULL)) { MessageBox("Error"); return NULL; } CDC memDC; memDC.CreateCompatibleDC(&screenDC); CBitmap bmpBitmap; bmpBitmap.CreateCompatibleBitmap(&memDC, 50,100); CBitmap *pOldBitmap = memDC.SelectObject(&bmpBitmap); CBrush blackBrush(RGB(0,0,0)), colorBrush(RGB(255,0,255)); CBrush* pOldBrush = memDC.SelectObject(&blackBrush); memDC.Rectangle(0,0,50,100); memDC.SelectObject(&colorBrush); memDC.SetTextColor(RGB(255,0,255)); //memDC.SetBkColor(RGB(255,255,255)); memDC.SetBkMode(TRANSPARENT); memDC.DrawText("WTF", CRect(0,0,50,100), DT_SINGLELINE | DT_NOCLIP | DT_LEFT); memDC.SelectObject(pOldBitmap); memDC.SelectObject(pOldBrush); memDC.DeleteDC(); img->CreateFromHBITMAP(bmpBitmap); return img; } The problem I'm having is that the text "WTF" doesn't show up in magenta like it says unless I add the line "generatedImg->SetPaletteColor(idx+1, RGB(255,0,255));". If I take that out, the GIF doesn't show up right. The bi

    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