Thought it would be worthwhile sharing some information regarding GDI+ and its Image Attributes object. Specifically, we are going to discuss the color matrix. This is a 5x5 matrix/grid, variable type: Single.
GDI+ uses this matrix to change image color values, on-the-fly. This prevents you from having to manipulate and change individual color values by hand. Since the matrix is basically a batch, of sorts, of formulas applied to each pixel value, there is little that cannot be done and limited only by imagination or creativity.
The project included below is provided to get your feet wet. There exists on many sites sample matrices you can use to achieve many different color transformations. Wouldn't be a bad idea to start collecting these and storing away for future use. This project, though truly a demo, offers a method to save and load your personal collections of matrices (assuming they were saved while using the demo).
The project is also designed to punch in any matrix values you want and see the results with a click of a button. Like what you see after your changes? Save the matrix or copy the matrix to the clipboard and paste into your project.
I've included a sample PNG in the file, but the project allows you to select images from your computer. I'm sure some of you will ask questions, but let's not discuss modifying the demo project... let's talk about GDI+ image attributes.
This is a good link to read a bit more about GDI+ color matrices. The link starts at page 7 at that site, be sure to browse some of the other pages too.
Here is another site that has sample matrices while also discussing the color matrix. You'll also see where I got the sepia matrix from, hint hint. In the demo project below, I am also defining brightness differently than most. But that shouldn't matter. Use whatever matrix you wish for your particular needs.
Screenshot below is a more complex matrix. Most matrices are just 3-5 non-zero entries.
![Name: Untitled.png
Views: 93
Size: 49.7 KB]()
Note for non-US locales, use US decimals. The project expects that format in the textboxes.
Until I fix this and repost, in Form_Unload, move the line "GdiplusShutdown m_Token" to just before the "End If" line. Can't shut down GDI+ then attempt to dispose of a GDI+ object, now can we?
GDI+ uses this matrix to change image color values, on-the-fly. This prevents you from having to manipulate and change individual color values by hand. Since the matrix is basically a batch, of sorts, of formulas applied to each pixel value, there is little that cannot be done and limited only by imagination or creativity.
The project included below is provided to get your feet wet. There exists on many sites sample matrices you can use to achieve many different color transformations. Wouldn't be a bad idea to start collecting these and storing away for future use. This project, though truly a demo, offers a method to save and load your personal collections of matrices (assuming they were saved while using the demo).
The project is also designed to punch in any matrix values you want and see the results with a click of a button. Like what you see after your changes? Save the matrix or copy the matrix to the clipboard and paste into your project.
I've included a sample PNG in the file, but the project allows you to select images from your computer. I'm sure some of you will ask questions, but let's not discuss modifying the demo project... let's talk about GDI+ image attributes.
This is a good link to read a bit more about GDI+ color matrices. The link starts at page 7 at that site, be sure to browse some of the other pages too.
Here is another site that has sample matrices while also discussing the color matrix. You'll also see where I got the sepia matrix from, hint hint. In the demo project below, I am also defining brightness differently than most. But that shouldn't matter. Use whatever matrix you wish for your particular needs.
Screenshot below is a more complex matrix. Most matrices are just 3-5 non-zero entries.
Note for non-US locales, use US decimals. The project expects that format in the textboxes.
Until I fix this and repost, in Form_Unload, move the line "GdiplusShutdown m_Token" to just before the "End If" line. Can't shut down GDI+ then attempt to dispose of a GDI+ object, now can we?