TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
uus99
NA
1
0
Problem with drawing on B&w or Gray TIFF using GDI+
Feb 12 2005 12:13 AM
Problem with GDI+ in Visual C++ 6.0 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
Reply
Answers (
0
)
Vertical Sync event
VMR Interfaces