1. Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 19, 2000
- 472 views
------=_NextPart_000_0018_01C03962.DC0AD6D0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all. I need to be able to "cut" a section from a bitmap in Win32 and save the = resulting image either to memory or HD. The problem I have is that the "cut" I want from the bitmap is = parallelogramish I then want to map the cut parallelogram to a regular rectangle. eg. ; / / | | / / --------> | |=20 / / | | ; or even / \ =20 / \ | --------------|=20 / \ | | / \ -----------> | | \ / | | \ / |---------------| \ / \ /=20 Are there any functions in Win32 (either via win32lib or to wrap myself) = that can do this (I looked, couldn't see anything)? If not, can anyone recommend some code or a method to achieve this? I = can't think=20 of a way to handle this, especially as the sides probably won't be of = perfect lengths=20 (the shape cut may often be more of a trapezoid). Perhaps someone knows of a Euphoria library or a dll I can call to do = this? Code doesn't have to be Win32 or Euphoria. I just need to get some = ideas. Many thanks for any help. Mark ------=_NextPart_000_0018_01C03962.DC0AD6D0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2920.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi all.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I need to be able to "cut" a section = from a bitmap=20 in Win32 and save the resulting</FONT></DIV> <DIV><FONT face=3DArial size=3D2>image either to memory or = HD.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>The problem I have is that the "cut" I = want from=20 the bitmap is parallelogramish</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I then want to map </FONT><FONT = face=3DArial=20 size=3D2>the cut parallelogram to a regular rectangle.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>eg.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =20 ; =20 |--------------|</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =20 =20 = =20 |</FONT></DIV> <DIV><FONT face=3DArial size=3D2> =20 =20 / =20 | </FONT></DIV> <DIV><FONT face=3DArial=20 sp; =20 nbsp; =20 =20 |</FONT></DIV> <DIV><FONT face=3DArial size=3D2>/------------=20 nbsp; =20 |--------------| </FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>or even</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> /=20 </FONT></DIV> <DIV><FONT face=3DArial size=3D2> = / =20 nbsp; =20 | --------------| </FONT></DIV> <DIV><FONT face=3DArial=20 nbsp; =20 =20 |</FONT></DIV> <DIV><FONT face=3DArial=20 sp; =20 \ ----------->=20 =20 =20 |</FONT></DIV> <DIV><FONT face=3DArial=20 p; =20 =20 |</FONT></DIV> <DIV><FONT face=3DArial=20 sp;=20 nbsp; =20 |---------------|</FONT></DIV> <DIV><FONT face=3DArial size=3D2> = \ =20 /</FONT></DIV> <DIV><FONT face=3DArial size=3D2> \ = /=20 </FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Are there any functions in Win32 = (either via=20 win32lib or to wrap myself) that can do</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this (I looked, couldn't see=20 anything)?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>If not, can anyone recommend some code = or a method=20 to achieve this? I can't think </FONT></DIV> <DIV><FONT face=3DArial size=3D2>of a way to handle this, especially as = the sides=20 probably won't be of perfect lengths </FONT></DIV> <DIV><FONT face=3DArial size=3D2>(the shape cut may often be more of a=20 trapezoid).</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Perhaps someone knows of a Euphoria = library or a=20 dll I can call to do this?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Code doesn't have to be Win32 or = Euphoria. I just=20 need to get some ideas.</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Many thanks for any help.</FONT></DIV> <DIV> </DIV> ------=_NextPart_000_0018_01C03962.DC0AD6D0--
2. Re: Need help getting odd shape from a bitmap.
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Oct 18, 2000
- 466 views
Mark Brown wrote: > Are there any functions in Win32 ... You can always just use getPixel/setPixel. A bit slow, bit it works. -- David Cuny
3. Re: Need help getting odd shape from a bitmap.
- Posted by Al Getz <xaxo at AOL.COM> Oct 18, 2000
- 454 views
- Last edited Oct 19, 2000
Are you intending to use the results for special effects, or do you intend to fill in the outer areas with a background color retaining the original aspect ratio? --Al
4. Re: Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 19, 2000
- 458 views
Hi Al. > Are you intending to use the results for special effects, or do you intend > to fill in the outer areas with a background color retaining the original > aspect ratio? My plan is to cut textures from photo's. It is part of a program that I am lamely writing that is sort of an attempt at photogrammetry (more photo interpretation really). The intention is to write something I can use to more easily create models for Morfit, using real photo's. I have tried many of the photogrammetry programs on offer and find them difficult and slow to use.. The idea is to rubber band an area of an object in a photograph. My intention at the moment is to deal only with rectangularish objects like buildings. However, the rubber banded shape is never going to be perfectly horizontal / vertical in the image (and in fact I don't want it to be as I want to get as much information about the object as I can from a single photo). I need to be able to cut the texture from the photo and have that squished, moulded, stretched into the rectangular bitmap. A rectangular bitmap can be correctly applied to a rectangular polygon using Morfit. I can't see a way to do it at the moment! Thanks Mark PS....should I have include [BCF] - "Build my code for me" request in my subject!!
5. Re: Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 20, 2000
- 458 views
I think I have a solution to my bitmap cutting problem (not actually *my* solution but now that I've been shown how to do it, it all makes sense.) Mark
6. Re: Need help getting odd shape from a bitmap.
- Posted by Sid Sidebottom <sid.sidebottom at ST.COM> Oct 19, 2000
- 448 views
Mark Brown wrote: > > I think I have a solution to my bitmap cutting problem (not actually > *my* solution but now that I've been shown how to do it, it all > makes sense.) > I have been following this, any hints as to how you are going to do it? Sid
7. Re: Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 19, 2000
- 443 views
Hi David > You can always just use getPixel/setPixel. A bit slow, bit it works. That was one thing I was considering for my kludge. However, I can't think of a way to expand or contract the image to fit within the regular rectangular shaped bitmap. eg.. ; / / | | / / --------> | | / / | | ; I think I can manage the above one that way if I just scan left to right on the source and use the same x co-ord for the start in the destination. I think this will only work if the source is a perfect parallelogram. If say, the base in the source is larger than the top then to map to the rectangle on the right I will need to discard some pixels as I go but how to do that and still maintain the integrity of the image? This one is even worse (and more like what I am trying to cope with).... / \ / \ | --------------| / \ | | / \ -----------> | | \ / | | \ / |---------------| \ / \ / I can't just scan pixel in the source left to right and plot in the destination. I really need a way to say start in that top corner and scan across and down in the direction of each diagonal(ish) line in the source. I'm really stumped. Mark
8. Re: Need help getting odd shape from a bitmap.
- Posted by Al Getz <xaxo at AOL.COM> Oct 19, 2000
- 443 views
It sounds like your going to stretch parts of the bitmaps to fit the rectangle--i hope you realize that for many shapes your going to get nothing short of op-art out of it? When you try to map a diamond to a rectangle you end up s t r e t c h i n g a few points to a whole line for some lines, while retaining full length for other lines. I'd like to see what you end up with too. WinAPI has the function call 'StretchBitmap()' which can be used on individual lines with a little care. If the results are not acceptable, you'll have to write your own stretch algorithm. Depending on what your going for, this might be the coolest method as you can then vary the algorithm to obtain differing effects. Hope you can post some near final results when you decide. Good luck with it. --Al
9. Re: Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 22, 2000
- 481 views
Hi again Sid. Actually you can click more than 4 points (not less though) It just ignores the extra points. You can get some weird effects by clicking your second or third point in a weird spot. Mark (3:52 AM) 8 )
10. Re: Need help getting odd shape from a bitmap.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Oct 22, 2000
- 487 views
Hi again Al. Actually you can click more than 4 points (not less though) It just ignores the extra points. You can get some weird effects by clicking your second or third point in a weird spot. Mark (3:52 AM) 8 )