Monday, May 25, 2009

Copyrighter v0.5 - Texturing and roundedborders added!

by Hasan Karagülmez
Another big update, texturing support has been added!

copyrighter v0.5 heartstexture and roundedborders

That's Copyrighter v0.5, with a new roundedborder around the image, a textured border next to that, and another normal border as the outer border. All borders can be textured!


Download
You can download v0.5 by clicking HERE (352kB zip-file).

The executable itself is only 88.5kB in size, and starts up instantly.

Included in the zip are:

  • all the textures used in the samples below
  • an HTML-page, containing a list of all the available colours
  • a text-file, containing a concise explanation of all available borders
  • a sample preview image (which you can change yourself if you want), sample modifydescriptor.xml file and sample copyright-image.


Usage:
Functionally, it's the same as all previous versions.

Basically, just drag-and-drop images onto the main Copyrighter-window, the result is outputted in a subdirectory called "Processed".


So... what are textures?
For those who don't know, textures are (usually) small files containing a certain pattern. These patterns often seamlessly fit next to each other. This makes it ideal for use in games (say, an entire wall can be textured using only a single small image repeated many times), but it also means we can use it to texture borders in Copyrighter :)

Where do I find textures?
Textures can often be found for free, e.g.:

And many many more!

This blogpost has a link to twelve other sites containing free textures:

http://www.bittbox.com/freebies/freebie-roundup-12-places-to-download-free-textures/

The heart texture used above is from this page:

http://www.new-textures-and-3dmodels.com/heart-textures-6.html

Just Google for "Free textures" if you want to search for other sites. You're of course also free to create your own texture :)

It's best not to use huge textures, normally something with an width and/or height of 75 pixels is just fine.

How do I use them?
In order for textures to be used, I've defined some new XML-attributes with which you can designate what to use and how the texture should behave.

For example, the solidcolourborder only had the colour attribute, which you could use as e.g. colour="pink".

Well, now you can also use "texture", "texturemode" and "texturescale". The texturemode and texturescale are optional, but texture is required.

For example, the sample Copyrighter v0.5 screenshot used this XML:


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="solidcolourborder" colour="pink" width="10" />
<modify type="solidcolourborder" width="60" texturescale="1.0" texturemode="default" texture="hearttexture.jpg" />
<modify type="roundedborder" colour="pink" width="8" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.5" position="bottomright" percentage="50" filename="example.png" />
</modifiers>

Important: Place any texture you've got in the same folder as the Copyrighterer.exe folder, this ensures it can be found.

Here's an example with texturescale set to 0.5, as you can see, the texture is smaller and more textures are used to fill up the rectangle:

copyrighter v0.5 heartstexture at texturescale 0.5

And here's an example with texturescale set to 2.0, the texture is now twice as big:

copyrighter v0.5 heartstexture at texturescale 2.0

So, basically, with texture you set the filename of the texture. With texturescale you can set the size of the texture and with texturemode you can set how the texture should behave.

This is because there are a couple of options, the default behaviour is that the texture is copied to the left and to the bottom untill the entire rectangle is filled with the texture.

Another important texturemode is scaletofit. This, as the name suggests, scales one texture so that ONE texture fills the ENTIRE rectangle. This can be used for if, for example, you've got a texture which is in fact a gradient.

So, another sample using a gradient image would be:


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="solidcolourborder" colour="black" width="10" />
<modify type="solidcolourborder" width="62" texturemode="scaletofit" texture="blacktowhitegradient.jpg" />
<modify type="solidcolourborder" colour="black" width="2" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.5" position="bottomright" percentage="25" filename="example.png" />
</modifiers>


which gives the following result:

copyrighter v0.5 gradient scaletofit

Transparent Textures
Transparent textures are supported, e.g. here's an border using a hearts-texture, and over it another transparent border. You can accomplish this by setting the width of the underlying border to 0 (zero).
Remember, that if you want to create a transparent border, you should use a file-type which supports transparency, e.g. PNG.


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="solidcolourborder" colour="black" width="3" />
<modify type="solidcolourborder" width="0" texture="hearttexture.jpg" />
<modify type="solidcolourborder" width="62" texturemode="scaletofit" texture="blackgradient.png" />
<modify type="solidcolourborder" colour="black" width="2" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.5" position="bottomright" percentage="25" filename="example.png" />
</modifiers>


Which gives the following result:

copyrighter v0.5 overlayed transparent gradient border


Overlaying a texture which contains transparency, is, however, not fully supported IF the underlying border is a colour. The previous sample works, because hearttexture.jpg is underneath the blackgradient.png border.

Roundedborder texturing
Because the roundedborder basically consists of two borders (the foreground and background), you can texture them both. This is a pretty specific case, though, as only a little bit of the background will be shown, but if that's what you want to do then you can :)

Here's a closeup of the edge of a roundedborder, untextured, set with a foreground- and backgroundcolour which has the following close-up result:

copyrighter v0.5 roundedborder blue blackground green

The green colour is the background, the blue colour is the roundedborder itself.
The foreground of the roundedborder is textured via the usual texture, texturemode and texturescale attributes.

The background can be texturesset with backgroundtexture, backgroundtexturemode and backgroundtexturescale attributes. Of course, you can just specify a colour for the background with "backgroundcolour" :)

Here's a sample, which is actually the content of the modifydescriptor.xml file containted in the zip, of an untextured roundedborder. Note that the background is explicitly stated as black, the same as the surrounding solidcolourborder:

<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="solidcolourborder" percentage="6" colour="black" />
<modify type="roundedborder" width="10" colour="white" background="black" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.5" filename="example.png" percentage="25" position="bottomright" />
</modifiers>


which gives the following result:

Copyrighter v0.5 mainimage


Final Words
So, to sum it up, there's a new border you can use called roundedborder.

Texturing for each border is done with the attributes texture (required), and the optional texturemode and texturescale attributes.

So basically that's it!

If you want to more extensive information, please check back to the blogpost about v0.3 and v0.4. A text-file with simple explanations is included in the zip-file. Of course, if you've got any questions or need help with textures or whatever, just let me know :)

Known issues
  • Textures with transparency ARE supported, but might not always be rendered correctly. Transparent textures work best if the underlying border are also textured.
  • Supplying a texture AND a colour for a border is not supported, although you're free to try it out :)

If you encounter any problems, as always, feel free to contact me :)

Thursday, April 30, 2009

Copyrighter v0.4 - Multithreading implemented!

by Hasan Karagülmez
So yeah, there you have it, Copyrighter has got multithreading now! :)

copyrighter v0.4 mainwindow
click for larger image

Download
You don't have to do anything to take advantage, just download the new zip-package HERE (366kB zip-file).

A sample, copyrightimage, xml-file and preview image are included, as well as a small readme text-file.

The executable itself is only 83.5kB, 2.5kB smaller than v0.3 :)

Additional information
Due to the architecture in place, multithreading was a relatively easy affair and I'm also pretty happy with the performance improvements. Testing on my Quad-core 2.4GHz Q6600 processor shows an improvement of around 2 times compared to the v0.3 of Copyrighter.

I've tested this with a batch of 3440 images (!!!), with image-sizes varying from 800x533 pixels (a typical size I use for uploading images to the web) to about 2523x660 pixels, with filesizes varying of 84kB to about 556kB. I get almost 1100 images per minute with Copyrighter v0.4, versus almost 500 images per minute with version 0.3.

Yes, I'm pretty happy with this kind of performance :)

In this version, all the work is done on seperate threads, away from the UI-thread, which keeps the main program also nice and responsive :) Copyrighter v0.3 did all the work on the user-interface (UI) thread (which is why v0.3 hangs when processing), so that's fixed now!

In fact, whilst it is processing, you can just drag-and-drop a new batch of images and they'll be processed as well. I've had it up to 24 simultaneous threads without a problem, processing different batches :)

Threading
Copyrighter v0.4 divides the work over the present (logical) processors in the system. Copryrighter starts with 2 threads (used in the main window), and when images are dropped, the amount of work is divided over the available processors. So, on my quad-core machine, there are 4 logical processors, and so (at most) 4 threads are created which will do the work. Copyrighter will then have 6 threads.

If you've got a dual-core machine, the amount of work will be spread out over 2 additional threads, so Copyrighter will have then have 4 threads.

When you drag-and-drop, that work will again be spread out over the available processors. So, in my quad-core machine, if Copyrighter was at 6 threads, it will then have 10 threads after an additional drag-and-drop.

When all work finishes, Copyrighter will fall back to the default 2 threads.


Final Words
That's it really :)

The working is still the same, so please check the blog-entry regarding v0.3 for extensive information.

Basically, just drag-and-drop images onto the main program-window, images are outputted in a subdirectory called "Processed".

I've always wanted to implement multithreading in Copyrighter and I'm glad I did. I hope this program can help you, let me know what you think - I'd really appreciate it :)

Tuesday, April 21, 2009

Copyrighter v0.3 - Batch Processor for Images

by Hasan Karagülmez
Introduction
Well, after recently getting my driver's licence, I of course immediately went driving around programming some more :)

This is actually a tool I've created before (hence it's version 0.3) but haven´t given it that much attention, mostly due to time constraints... Anyway, the goal of this tool, as the name suggests, was originally created to add a copyright picture to a series of pictures and add borders.

I´ve also created it to make myself work with a couple of programming aspects, such as Design Patterns (Decorator, Chain-of-Responsibility, Strategy, Singleton, Factory patterns are all used here) and keep on working with C++ and Win32, as I do C# for a living :)

Well, enough of the chit-chat, how is it used?

Download

UPDATE: v0.4 is available! Click Here


I'll give this one upfront :)

You can download Copyrighter v0.3 from here (400kB zip file).

The executable itself is only 86 kB, and startup is instant. A sample copyright-image, preview-image and XML-file are included in the zip.

Usage
Images are processed by dragging and dropping onto the Copyrighter Window. Images of type TIFF, BMP (bitmap´s), PNG and of course JPG (jpeg´s) are all accepted.

Processed images come in a subfolder of the executable, called "Processed". So, if the executable location is C:\Copyrighter v0.3.exe, the images will be outputted to C:\Processed\.

Copyrighter uses an XML-file with the "modifydescriptor.xml" which tells it what to do with each image.

The result of the current modifydescriptor.xml file is always displayed on the main window (click for larger image):

copyrighterv0.3 mainimage

To achieve the border effect in this sample, one thin white border and one big black border, the following XML can be used:


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="solidcolourborder" percentage="3" colour="Black" />
<modify type="solidcolourborder" width="5" colour="White" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.80" filename="example.png" percentage="25" position="bottomright" />
</modifiers>


Pretty simple huh?

As you can see, Copyrighter works with so-called "modifiers" to identify the action that should take place.

So, in this sample, there are two borders with a solidcolour, an image, and the copyrightimage - all described with modify-elements.

Let's delve in a little bit further.

Solidcolourborder
The solidcolourborder creates a border with a specific colour.

The size of the border can be described in two ways:

  1. as a percentage of the size of the image, via the percentage attribute
  2. as an absolute value, via the width attribute.


In the example, the first solidcolourborder uses a percentage via percentage="3", and the second uses an absolute value with width="1".

The last attribute for a solidcolourborder is the colour. You can use any colour such as "blue" or "green", etc. A list of available colours with their names is available here. Casing is not important, so you're free to write "blue" or "Blue".

Image
Image describes where the processed image comes in the stack of modifiers.
There is only one attribute which can be set, which is the opacity. Any value between 0.0 (completely transparent) and 1.0 (opaque). You can leave this at 1.0 :)

Copyrightimage
Copyrightimage is the modifier which describes how the copyrightimage should be superimposed on the image. As you can see, it comes after the image modifier, because it is on top of the actual image.

There are a couple of attributes which can be set for the copyrightimage-modifier

  • opacity, any value between 0.0 and 1.0 can be used. I find that 0.8 creates a nice blend with the actual image, but you're of course free to use what you want.

  • filename, the filename of the image that should be used as the copyrightimage. If you want to use transparency, make sure you use the PNG-format using at least 16-bit to preserve transparency.

  • percentage, to describe how big the copyrightimage should be, as a percentage of the of the actual image.

  • position, the place where the copyrightimage should be placed. There are a couple of options, namely: "topleft", "topright",
    "bottomleft", "bottomright" and "middle".


Widescreenborder
There is one more modifier that you can use, which has not handled yet, and the is the widescreenborder. It uses the same attributes as the solidcolourborder, e.g.:


<modify type="widescreenborder" percentage="5" colour="Black" />


Which will create borders only on the top and bottom of an image, the same effect you will see with widescreen movies.

For example, the following XML:


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="widescreenborder" percentage="5" colour="Black" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.80" filename="example.png" percentage="25" position="bottomright" />
</modifiers>


Would yield the following result (click for larger image):
copyrighter v0.3 widescreenborder

Because this is just another modifier, you are free to mix all results. For example, you can use a widescreenborder-modifier with solidcolourborder-modifiers.


<?xml version="1.0" encoding="UTF-8"?>
<modifiers>
<modify type="widescreenborder" width="10" colour="Navy" />
<modify type="solidcolourborder" percentage="3" colour="Orange" />
<modify type="solidcolourborder" width="5" colour="LawnGreen" />
<modify type="image" opacity="1.0" />
<modify type="copyrightimage" opacity="0.80" filename="example.png" percentage="25" position="bottomright" />
</modifiers>


...yields the following result (click for larger image):

copyrighter v0.3 mixedmodifiers

Advanced users, setting colour
If you don't want to use a colour out of the linked list of colors, and you know about hexadecimals and RGB values, you can also set a very specific colour in a different way.

Let's take the colour FFDE8384.

This should be splitted up in 1 byte values, and you need two hexadecimals to describe one byte.

FF - this is actually the opacity of the colour, you can leave this at FF, which means the colour is fully opaque (i.e. no transparency at all) all the way to 00 for fully transparant.
DE - Red, 222 decimal
83 - Green, 131 decimal
84 - Blue, 132 decimal

FF000000 would be black (red, green, and blue are all 0). FFFFFFFF would be white (red, green and blue are all 255: the "brightest" setting).

You don't need to play around with hexadecimals to set a colour though, there are numerous online colourpickers you can choose from.

Some online colourpickers use a leading hash-symbol, e.g. "#A9BF34". Just make sure you substitute "#" with "FF" when setting it as a value in the XML, so it would be "FFA9BF34". Also make sure that the value is in ALL CAPS.

If you do not get the colour right, the entire modifier will be ignored, which means that the border will not be shown :)

If you've got questions or problems regarding this, feel free to comment! I'm happy to help you out.

Known issues
As this is still a pretty early version, there might be some issues you'll encounter.

  • User Interface hangs when processing
    Copyrighter currently becomes unresponse as it's processing files. Please wait for it to finish.

  • Preview might show (slight) inconsistencies
    For example, the border on the left-hand side of the image might appear smaller than the right-hand side. This is usually not a real problem, it's just that the preview is slighty skewed.
    If you are unsure, simply try a single image and see what the result is like, it's likely just fine.

  • You cannot border the copyrightimage
    Currently you cannot put a border around the copyrightimage. If you try to do so, the copyrightimage will disappear.

  • Display only reads the modifydescriptor.xml file during program start-up.

  • This means that if you change the contents of modifydescriptor.xml whilst Copyrighter is running, the new results will NOT be shown in the current window. However, it will affect the processed files.
    Close and re-open Copyrighter to view the result of a modified modifydescriptor.xml in the preview window.

  • Using a percentage might fail
    When using a lot of modifiers mixing widescreenborder and solidcolourborders, using a percentage with solidcolourborders might not work correctly. Use the width instead of percentage instead in this case.


Final Words
Well, thanks for looking and if you use this program just drop me a line or place a comment, I'd really appreciate it :)

If you need some help creating a copyright-image, let me know, perhaps I can help you out. If you've found a certain bug not yet listed, post a reply or e-mail and I'll see what I can do. If you´ve got some kind of border in mind that you´d like to see implemented, also, let me know - maybe I can implement it.

All my images on http://pix.ie/hask that use a border have been created with Copyrighter if you want to view more samples.

If you've got any questions, also feel free to place a comment or e-mail to Srand0 AT yahoo DOT com. That's a zero in Srand0 btw :)


Thanks,

Hasan

Tuesday, April 7, 2009

Driver's Licence GET!!!!

by Hasan Karagülmez
Passed the practical exam today for my Driver's Licence YAY!!!! :D

I'M SO HAPPY!!! :D