Originally posted by: richard
Dears,
I have a problem with adjusting a contrast and a brightness of any image. I read a MSDN Library GDI+ Reference. I found an article called "Using a Color Matrix to Transform a Single Color" (Platform SDK/Graphics & Multimedia/GDI+/Using GDI+/Recoloring). There is a color matrix for adjusting colors of an image. I thing, that the first three values on the diagonal of the matrix adjust the contrast of image and the first three values on the last row of the matrix adjust the brightness.
My problem is, that if I want multiply color by factor greater than one, then I get an image with corrupted colors. There is a WWW page to demonstrate this behaviour:
http://www.raz-dva.cz/r.sima/gdiplus.html
Does anybody know, why I get such result?
Thank you for any information,
Richard
Originally posted by: Heway
VC6, Win2K 2SP
void CGditestView::OnGdi()
CPoint ptOld;
void CGditestView::OnGdiplus()
HDC hDC = ::GetDC(GetSafeHwnd());
Pen myPen(Color(255, 0, 0, 255), 1);
for( int i = 0; i < 1000; i++)
::ReleaseDC(GetSafeHwnd(), hDC);
I just wrote two small function to compare the draw speed of gdi and gdi+. not include the complex functions, just draw lines.
The result is the gdi+ is more than ten times slower than gdi. Does this mean gdi+ is not useful in simple usage?
{
DWORD nCost = ::GetTickCount();
HDC hDC = ::GetDC(GetSafeHwnd());
HPEN hPen = ::CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
::SelectObject(hDC, hPen);
::MoveToEx(hDC, 10, 10, &ptOld);
int i = 0;
while( i < 1000)
{
::LineTo(hDC, 10 + i, 600);
::MoveToEx(hDC, ++i + 10, 10, NULL);
}
::MoveToEx(hDC, ptOld.x, ptOld.y, NULL);
::SelectObject(hDC, hOldPen);
::DeleteObject(hPen);
::ReleaseDC(GetSafeHwnd(), hDC);
nCost = ::GetTickCount() - nCost;
CString strText;
strText.Format("Total cost of GDI is %d ms", nCost);
MessageBox(strText);
}
{
DWORD nCost = ::GetTickCount();
Graphics graphics(hDC);
{
graphics.DrawLine(&myPen, 10 + i, 10, 10 + i, 600);
}
nCost = ::GetTickCount() - nCost;
CString strText;
strText.Format("Total cost of GDI+ is %d ms", nCost);
MessageBox(strText);
}
Originally posted by: lkilljs
.
Reply
Originally posted by: Boogie
I want To Flood fill color
in_bitmap() is only to check whether the coordinate is inside the dimensions of the bitmap (flood fill() crashes otherwise) NOTE: go to this adress for more options: http://www.codecodex.com/wiki/index.php?title=Implementing_the_flood_fill_algorithm#Implementations bool in_bitmap(int x, int y) { if ( x >= 0 && x < bWidth && y >= 0 && y < bHeight) return true; else return false; } void flood_fill(HDC dc, int x, int y, COLORREF bColor, COLORREF aColor) { if (GetPixel(dc,x,y) != bColor) return; SetPixel(dc,x,y,aColor); if ( GetPixel(dc,x,y+1) == bColor && in_bitmap(x,y+1)) flood_fill(dc,x,y+1,bColor,aColor); if ( GetPixel(dc,x,y-1) == bColor && in_bitmap(x,y-1)) flood_fill(dc,x,y-1,bColor,aColor); if ( GetPixel(dc,x+1,y) == bColor && in_bitmap(x+1,y)) flood_fill(dc,x+1,y,bColor,aColor); if ( GetPixel(dc,x-1,y) == bColor && in_bitmap(x-1,y)) flood_fill(dc,x-1,y,bColor,aColor); } it sometimes overflows the stack lol :) however, it is still used because it is easy to read
ReplyOriginally posted by: Gregory Kaufman
I've been able to save a GDI+ Bitmap to a tiff file, but when I try to save it as *.BMP, no paint application can open it. They complain about "invalid header" (Corel PhotoPaint).
Can anyone help me?
Thanks,
Greg
ReplyOriginally posted by: richard
Hello,
does anybody have an experience with GDI+ with C++Builder. I have MS SDK from latest MSDN subscription (November 2001?). I download a distributable GDI+'s DLL (which one is not included into SDK). There is first example on the WWW page
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/urecoloring_61lx.asp
I try the example using VC++ and C++Builder. I create two simple applications. Problem is, that I get two images running a VC++'s application, but I get only one image running a C++Builder application.
I debug the C++Builder appl and I found, that method ImageAttributes::SetColorMatrix() fails. Value of property
imageAttributes.lastResult=2 /*Gdiplus::InvalidParameter*/
I do not know why. Does anybody knows?
Thank you for answer,
Richard
PS: I must create a new gdiplus.lib from the MS gdiplus.dll, because C++Builder does not understand a format of MS gdiplus.lib. I user a Borland implib tool to do that.
Originally posted by: kizmo
Hi..
I'm making an App that read TTF file and make image from string inputed.
But I got a problem in reading TTF file.
Some TTF file is read well, But some Never..
"AddFontFile " function returns 10 ( "FileNotFound" in Status enumeration)
But there is that file..
I check it over hundred times..
What I miss? I can't find it..
Reply
Originally posted by: John
how do you resize an image? - i want to open an image resize it then save the resized image - but using scaletransform doesnt seem to work cause i just end up with the image being the same size as when i started.
thanks
John.
Originally posted by: Max
HI
Did anyone find a way to do the equivalent of SetROP2
Max
Originally posted by: Neste
How to draw animated gif?
Reply