![]() |
|
BITMAP Border |
Onewing
Member #6,152
August 2005
![]() |
I haven't actually written any code, but the idea is in my head and I though I'd share to get some general feedback. What I want to do is make function like the following: void draw_border(BITMAP *bImage, BITMAP *bBorder); This function will draw the bBorder image around the bImage. For example, if this were bBorder: http://comp.uark.edu/~spsilve/border.JPG And this were bImage: http://comp.uark.edu/~spsilve/image.JPG Then this should be the final output: http://comp.uark.edu/~spsilve/final.JPG The purpose of draw_border is to draw a border on what's actually seen. The image above is just a big square, so no problem there. If I were to have a circle, however, that would be a different situation. The border should follow the edges of the circle or polygon or whatever shape it is. Following the edges isn't really that difficult of a question, but what I've been wondering about is the corners. Notice above the border image turns with the picture. I've thought of a few different methods that might work, but I'm curious as to what you think. My favorite method so far consists of stripping the border image and drawing pieces of it at a time. Like taking the top one-pixel line of the image and drawing that around the entire space and then go to the next part of the border. Since this is going to be a one-time process in the actual program, it's okay if it takes a little time. Also note that above I used a very simple border. I could use something like a smile face and get some weird results. ------------ |
Richard Phipps
Member #1,632
November 2001
![]() |
I think this is more difficult than it seems if it can follow polygons and curves while keeping the pattern.. |
Onewing
Member #6,152
August 2005
![]() |
Thought it'd be a nice thing for my gui. If it's too complicated, I'll probably just throw it out. ------------ |
Hrvoje Ban
Member #4,537
April 2004
![]() |
Nevermind, I missunderstand question... |
Indeterminatus
Member #737
November 2000
![]() |
Quote: I think this is more difficult than it seems if it can follow polygons and curves while keeping the pattern.. That could be simplified by adding the restriction of a one-pixel-width border image, so there'd be no "real" pattern to keep. _______________________________ |
Ceagon Xylas
Member #5,495
February 2005
![]() |
Exactly right, Indeterminatus. |
Tobias Dammers
Member #2,604
August 2002
![]() |
I guess a generalized approach would be: The math involved in step 3 can be a bit tricky though, and you cannot use arbitrary shapes with arbitrary borders. --- |
GullRaDriel
Member #3,861
September 2003
![]() |
a simple way: use only one line of pixel gradient, and (pseudo code):
Note that it's only working for what you need. "Code is like shit - it only smells if it is not yours" |
Onewing
Member #6,152
August 2005
![]() |
Quote: That could be simplified by adding the restriction of a one-pixel-width border image, so there'd be no "real" pattern to keep. Yeah, I was thinking I might have to do that due to my limited knowledge. For simple borders above, that'd work fine, since the border is too complex. It would be nice to have different patterns though. Of course, most borders don't have patterns... Quote:
You also couldn't have very dramatic curves in your circle or polygon =/ The corners and curves are giving me some complications. I haven't tried to code anything yet, so I don't know how difficult it will be. Quote:
I guess a generalized approach would be: This sounds most like what I had in my head, especially number 2. However, you kind of lost me on number 4, I'll have to take a closer look. Quote: a simple way: Nothing wrong with simple. Even if I limit the borders to be pattern-less and only 1-pixel-width wide, you'd still be able to create a multitude of borders for simple, rectangular shapes. Thanks. ------------ |
Fladimir da Gorf
Member #1,565
October 2001
![]() |
In OpenLayer 2.0, you could make that textured border pretty simply: - First retrieve the collision Shape for the image object Actually the code does then exactly what Tobias suggested... OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Hrvoje Ban
Member #4,537
April 2004
![]() |
I'll made this two days ago, but didn't have change to post it till now:
First custom blender is set which for each pixel drawn with draw_trans/lit_sprite returns global_color. Then for each border, image is stretched into temporary and drawn into destination. This is when custom blender kicks in and draws entire image as solid color. This is repeated for every border except image is stretched less and less. Finally original image is drawn. It has two problems: It looks ugly and borders are drawn tiner as lines get more angled (see attached image, red primitive is default image). |
Onewing
Member #6,152
August 2005
![]() |
Cool! Although, at first glance, I haven't quite figured out how it works. Quote: It has two problems: It looks ugly and borders are drawn tiner as lines get more angled (see attached image, red primitive is default image).
Looks pretty good to me! I'll mess around with it when I get home and let you know if I have any other problems. ------------ |
Hrvoje Ban
Member #4,537
April 2004
![]() |
src is bitmap which should be bordered (not modified) Working is quite simple: When draw_trans_sprite/draw_lit_sprite are used they call special blender functions for each pixel they are about to draw (see Truecolor transparency). When my blenders are use they simple return current border color for every pixel. |
Fladimir da Gorf
Member #1,565
October 2001
![]() |
However, that can't do textured borders, but only solid color ones... (Though you could render several solid color borders to get the effect like in the screenshot) OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
|