 |

02-06-2004, 07:16 AM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
Trapezoid Blt?
|
|
I need to blt the image of a wall to a trapezoid. Trapezoids are not squares so bitblt and strechblt wont work. Any ideas?
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|

02-06-2004, 08:11 AM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
Bitblt will work won't it
I don't understand why bitblt won't work. Please enlighten me because as far as I know as long as you have a mask of an image any shape will work. I am sort of new to bitblt so I may be wrong.
|
|

02-06-2004, 08:16 AM
|
 |
MetaCenturion
Preferred language: Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: Hawaii, USA
Posts: 16,576
|
|
|
|
Indeed, you should be able to draw a trapezoid picture of a wall with BitBlt... if you make a mask of a trapezoid, and then make a picture of the wall shaped like a trapezoid, then you can do it.
|
|

02-06-2004, 01:28 PM
|
 |
Contributor
|
|
Join Date: Sep 2003
Location: Portland OR
Posts: 581
|
|
Use Stretchblt for trapezoidal...
Quote: Originally Posted by SpeedPear I need to blt the image of a wall to a trapezoid. Trapezoids are not squares so bitblt and strechblt wont work. Any ideas?
Please check out "VB_Image Perspective.zip" attached to this thread:
http://www.xtremevbtalk.com/t114884.html
I use this program (which uses stretchblt) to "reshape" a square bitmap into a trapezoidal shape to create perspective mapped textured "walls" for a pseudo-3d maze game I made.
Attached are a couple of screenies of the program at design and run time to show that the "reshaping" happens at run time;
And personnally I would never start a thread with a post saying something "won't" work. It's better to say " I don't know how to get such and such to work..."
|
|

02-06-2004, 03:11 PM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
RPG Newbie, thank you SO much. I still have a problem though.  . I need to repeatedly stretch the wall and bitblt it right inside the trapezoid. Your code seems to go off of a mask. Since the trapezoid always changes depending on angle, it would be impossible to have enough masks for it, unless I'm just not understanding your code. other than that, its exactly what I was looking for. I already know how to use bitblt, but needed to put a square onto a trapezoid. Others, thanks for trying...
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
Last edited by SpeedPear; 02-06-2004 at 03:18 PM.
|

02-06-2004, 03:21 PM
|
|
Regular
|
|
Join Date: Sep 2003
Location: Manchester, England
Posts: 69
|
|
I think to do that, and have it changed depending on angle, you'd need to be using some form of DirectX. Well it'd be easier that way, than finding a huge workaround in gdi or win32.
|
__________________
Currently working on:
Gdi32
|

02-06-2004, 03:29 PM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
I AM going to do it in bitblt or some other form of API. I've tryed DirectX and it's not my cup of tea. I figure it won't be worth it. I mainly want to specify 4 x,y coordinates to the function and have it draw it. Of course there will be other parameters to this function that i will make. This is urgent in case you guys were wondering...
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
Last edited by SpeedPear; 02-06-2004 at 03:37 PM.
|

02-06-2004, 05:21 PM
|
 |
Contributor
|
|
Join Date: Sep 2003
Location: Portland OR
Posts: 581
|
|
Programmatic masking
Quote: Originally Posted by SpeedPear I AM going to do it in bitblt or some other form of API. I've tryed DirectX and it's not my cup of tea. I figure it won't be worth it. I mainly want to specify 4 x,y coordinates to the function and have it draw it. Of course there will be other parameters to this function that i will make. This is urgent in case you guys were wondering...
Why is it that knee jerk response is so often DirectX. It's a great "tool", but you don't always have to use it for everything. (a hammer doesn't make a good screwdriver  )
Anyway, I think if you wise to be seeking another method if you have a lot of masks to generate (they can take up a lot of space).
Here is OnErrOr's Code Library thread to get you started with "programmatic" (on-the-fly) masking:
http://www.xtremevbtalk.com/t109862.html
|
|

02-06-2004, 05:53 PM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
actually, i've generated masks during run time. of course this od can be VERY slow, if i'm correct, on error does it differently then I did. Generally, I'm very good at looking at code and then learning from it. However, I don't know anything about DCs and that stuff. I generally bitblt from picture boxes ect. Any ideas on how I can port this code to about a 20-30 function to generate masks quickly?
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|

02-06-2004, 06:31 PM
|
|
Junior Contributor
Preferred language: * Expert *
|
|
Join Date: Feb 2004
Posts: 259
|
|
Device Contexts...
Quote: Originally Posted by SpeedPear actually, i've generated masks during run time. of course this od can be VERY slow, if i'm correct, on error does it differently then I did. Generally, I'm very good at looking at code and then learning from it. However, I don't know anything about DCs and that stuff. I generally bitblt from picture boxes ect. Any ideas on how I can port this code to about a 20-30 function to generate masks quickly?
Hmmm, on one hand you are complaining about speed and the other you say you don't know much about "DCs and such"...
I guess I can only tell you that using MemoryDCs ARE the answer to any speed concerns. They are the fastest way that VB has to manipulate graphics short of DirectX.
So my "idea" about porting OnErrOr's code (to what you specifically want to do) is to just try getting it to do what you want. Maybe the learning curve for working with Device Contexts is not as steep as you think. If you run into difficulties, post the code that is giving you problems and someone (maybe even OnErrOr) will try to help...
I noticed your "Aeon Nexus" page has a link to "New World Games" - Are you doing this project in connection with Bljashinsky?
|
|

02-06-2004, 09:29 PM
|
 |
Joseph Koss
Preferred language: * Guru *
|
|
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,313
|
|
This falls under the texture mapping algorithms..
..the idea is rather simple to understand tho not so simple to code up and make everything work .. but given a 4-cornered polygon specified by 4 X/Y pairs -- its simply a matter of looping through all the pixels within this polygon and convert the pixels X/Y to the textures (bitmap) X/Y .. and grabbing the color for the pixel from it.
I've used the term 'simply' when really its not so simple until you understand it.. very detailed docs can be found on GameDev
The hard part isnt so much the texture mapping - the hard part is optimising it.
|
|

02-07-2004, 07:40 AM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
I've started on something that goes pixel by pixel stretching it to the trapezoid with no luck. I have the basic concept on how to do it but for some reason I can't do it. About the site, BJashinsky's link is on it because I think he asked me to put it on it. I think that's how it was but I don't remember that well. He is not working on it. I guess you were also asking me that to know why I'm working on this instead of the RPG. The answer is that this game was a side project type deal. I guess it's time to start learning about Device Contexts and how to use them and take advantage of them for my programs. Do any of you know of a good tutorial to get me started?
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|

02-07-2004, 06:12 PM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|

02-07-2004, 07:16 PM
|
 |
Mostly Absent
Preferred language: * Expert *
|
|
Join Date: Jun 2002
Location: Christchurch, New Zealand
Posts: 2,006
|
|
If you're doing it pixel by pixel, you could try something like this:
Code:
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim startx As Integer
For j = 0 To srcPicture.Height
For i = 0 To srcPicture.Width
SetPixel destPicture.hdc, i + startx, j, GetPixel(srcPicture.hdc, i, j)
Next i
startx = startx + 1
Next j
End Sub
All you need is an image in a picturebox called srcPicture, and a picturebox called destPicture which will be drawn in. If you want to change the slope, just change the value which you're adding to StartX each loop.
|
__________________
Sometimes it happens feelings die, Whole years are lost in the blink of an eye
We once had it all but event conspired, Sometimes
Now that it's over, it is through, It gets me everytime I think of you
Sometimes It happens, feelings die, Sometimes
|

02-07-2004, 07:19 PM
|
 |
Senior Contributor
|
|
Join Date: Nov 2003
Location: California
Posts: 1,016
|
|
Not sure if you still need this but here's something from MSDN
|

02-07-2004, 09:30 PM
|
 |
Contributor
|
|
Join Date: Sep 2003
Location: Portland OR
Posts: 581
|
|
Device Context Tutorials
|

02-08-2004, 09:46 AM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 103
|
|
__________________
SpeedPear
Enter the pear
----------------------------------
Aeon Nexus Games
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
| |
|