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. Problem with GDI+ in Visual C++ 6.0

Problem with GDI+ in Visual C++ 6.0

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsquestioncsharpwinforms
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.
  • U Offline
    U Offline
    uus99
    wrote on last edited by
    #1

    Hello there, I'm using Visual C++ 6 with Platform SDK and trying to create a imaging program. The program is simple, where i the user can draw lines on a TIFF image. I'm using GDI+ for this purpose, but having one problem. The problem is that GDI+ just cannot draw on gray(8-bit)/black & white TIFF images or BMP for that matter. I dont know why. A simple test code is given below, void CGDIPlusDlg::OnButton8() { //gets current DC CDC *pDC=this->GetDC(); //gets Handle to DC HDC hdc=pDC->GetSafeHdc(); //Opens an image from disk Image img(L"c:\\mspaint.tif"); //target rectangle at coordinate 0,0 sizwe RectF r(0, 0, 100, 100); //Set graphics, and dest Graphics gr(hdc); RectF destRect(0, 0, 100, 100); //Draw original image-works fine gr.DrawImage(&img,destRect); //Create a blackpen (A,b,g,r), thickness 3 Pen blackPen(Color(255, 0, 0, 0), 3); //Start and end point PointF point1(0, 0); PointF point2(100.0f, 100.0f); //Draw line on image---doesnt work for BW images!! Graphics gr2(&img); gr2.DrawLine(&blackPen,point1,point2); RectF destRect2(100, 0, 100, 100); gr.DrawImage(&img,destRect2); } The image is created using MSPaint. Create a 100x100 image, draw something, and save as TIF. Save again by changing the image depth to black & white from the Image->Attributes menu. The program supposed to draw a diagonal line across the image, but it doest for the black&white version of tif. So, my problem is how to overcome this? Or, how can i programmatically convert a BW TIFF to color and work on it using GDI+? Oh yeah, can anyone try if this code works fine in C# or managed C++? Thanks, Usman

    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