Need help with designing an algorithm for solution to a jigsaw puzzle involving rectangular and right angled isoceles triangle pieces only. Images are in .bmp format. The pieces are in a single bmp file separated by black borders...........thnx in advance
Hmm... not sure what you mean.
A standard jigsaw solution can be easily achieved by numbering the pieces. The player doesn't know about this numbering but the game engine just checks for all the pieces to be in order for it to name the player a winner.
Thanks Mario.F for replying. What I meant was an original bmp will be there as well as a bmp containing the fragments separated by black border. An algorithm to scan this second bmp and come up with a resulting bmp that will be the original picture, is what I need help with. The pieces may be rotated by multiples 0f 90 degrees...........
- open a BMP file and scan for shapes
- open another BMP containing the puzzle - scan that for shapes as well
- try and fit the first set to the second
OK, how about we start with do you know how to read a BMP file?
Thank you Salem............yes I know how to read a bmp file in c. But the problem that I'm facing here is that the pieces of the puzzle are given in one bmp and they are straight edged(rectangular or right angled isoceles). So I did not understand what you meant by scanning for shapes..............some more help will be appreciated.
Well for example, if most of the BMP is white, and the shapes are marked by black lines, it's simply(*) a matter of finding a black pixel, then working your way round the image until you get back to your starting point. Along the way, you figure out from the turns in direction which shape you've got.