Application To Generate Combined Images Of All Image-Categories Possible Combinations
Posted by 12/21/2013 11:21:00 PM with No comments
on
[Update] The application is now updated to avoid "out of memory" exceptions.
On my last project I was working on a tree control which represents system business objects into hierarchical form. Each object has a workflow to go through and for each step in this workflow the object state changes.
So, one of the requirements was to add images beside each tree node for the system user to know the status of each tree node easily with the need to open a properties window or something like that.
This is easy but we have some points to clarify first:
So, after some thinking we came up with 2 approaches to choose from:
After doing the math, and it was so simple, we decided to go with the second approach to eliminate the extra requests the would be sent for each tree node to get all the three status images, so instead of 3 requests it would be only 1.
So, now comes the hard part. We need to generate the combined images. We could have wrote some code to generate the combined image of each tree node on the fly at run-time but we thought that this would not be the best decision as the status images are some static images which we already have at design time. So, there was no reason to go with that much run-time processing for each node when we could already generate all the possible images combinations we need.
That's why we decided to generate all the possible combinations that we could have for each system object status. Someone said that this would be too much images but we replied that it is not a problem as these images will be static and at the end of the days we are talking about a few mega bytes of static hard desk space not RAM.
We thought that doing the combination thing manually would be a shame and actually impossible as we have 25 x 4 x 7 = 700 combinations which means 700 images. Doing all of this work manually is so bad by all means especially when at some point the client decides to replace an image with another one or add a new image.
That's why I wrote a simple windows application which does all the hard work. You just give it each category images and in just seconds you get all your images.
Hint: the code related to generating all the possible combinations is built using the "Possibilities Cube" library I had posted before. If you are interested to read about it you can find it on Possibilities Cube Library - A Library Smart Enough To Calculate All Possibilities With Logical Conditions
Now, let's see some screenshots for the windows application.
Images for the first category (Cat01)
Images for the second category (Cat02)
Images for the third category (Cat03)
Adding images for each category on the application
Finally, the generated images
As you can see it is so easy to use the application and you can apply any modifications on the code to go with your specific business needs. Currently the code is set to export images into png format but you can change it as you wish in the code.
I didn't put much care into the application UI, graphics and so on as it is only for indoor usage to serve a certain need not to be a standalone product or anything like that so don't be turned off by the UI as at the end of the day it may help you save much time and effort.
Finally, you can download the application from here
Wish you will find this useful.
Good luck.
On my last project I was working on a tree control which represents system business objects into hierarchical form. Each object has a workflow to go through and for each step in this workflow the object state changes.
So, one of the requirements was to add images beside each tree node for the system user to know the status of each tree node easily with the need to open a properties window or something like that.
This is easy but we have some points to clarify first:
- Each system objects has three categories of status
- Cat01: is so business related so I will not go into details about it but let's just say that this type of object status should have one of 25 possibilities
- Cat02: is related to the type of change applied on the system object (added, edited, deleted, unchanged)
- Cat03: is also so business related but it is mainly about object change approval status. This object status should have one of 7 possibilities
- For each image tag added on the page there will be a request to the server and for sure its related response
So, after some thinking we came up with 2 approaches to choose from:
- Add three image tags beside each tree node and fill these tags with appropriate images according to the status of each object
- Add one image tag beside each tree node and fill this tag with only one image which is all the object 3 status images combined into one image. The specific image name will be built by concatenating the keywords for each category status. This way we don't have to switch case or detect each combination from real object status, just concatenate the keywords and voila we have the right image name
After doing the math, and it was so simple, we decided to go with the second approach to eliminate the extra requests the would be sent for each tree node to get all the three status images, so instead of 3 requests it would be only 1.
So, now comes the hard part. We need to generate the combined images. We could have wrote some code to generate the combined image of each tree node on the fly at run-time but we thought that this would not be the best decision as the status images are some static images which we already have at design time. So, there was no reason to go with that much run-time processing for each node when we could already generate all the possible images combinations we need.
That's why we decided to generate all the possible combinations that we could have for each system object status. Someone said that this would be too much images but we replied that it is not a problem as these images will be static and at the end of the days we are talking about a few mega bytes of static hard desk space not RAM.
We thought that doing the combination thing manually would be a shame and actually impossible as we have 25 x 4 x 7 = 700 combinations which means 700 images. Doing all of this work manually is so bad by all means especially when at some point the client decides to replace an image with another one or add a new image.
That's why I wrote a simple windows application which does all the hard work. You just give it each category images and in just seconds you get all your images.
Hint: the code related to generating all the possible combinations is built using the "Possibilities Cube" library I had posted before. If you are interested to read about it you can find it on Possibilities Cube Library - A Library Smart Enough To Calculate All Possibilities With Logical Conditions
Now, let's see some screenshots for the windows application.
Images for the first category (Cat01)
Images for the second category (Cat02)
Images for the third category (Cat03)
Adding images for each category on the application
Finally, the generated images
As you can see it is so easy to use the application and you can apply any modifications on the code to go with your specific business needs. Currently the code is set to export images into png format but you can change it as you wish in the code.
I didn't put much care into the application UI, graphics and so on as it is only for indoor usage to serve a certain need not to be a standalone product or anything like that so don't be turned off by the UI as at the end of the day it may help you save much time and effort.
Finally, you can download the application from here
Wish you will find this useful.
Good luck.