|
-
Jan 6th, 2003, 10:53 AM
#1
Thread Starter
Junior Member
Flipping An Image
ok im sure this is really simple, but i have looked through the 1st 15 pages of posts and cant find anyhitng
i have loaded an image into a picture box, its an inverted dib, so as its loaded as a bmp its upside down, so rather than playing with all the dib commands to load it properly i want to simply flip the image that has been loaded, is that possible?
-
Jan 6th, 2003, 02:52 PM
#2
Frenzied Member
dunno what a dib is, but to flip the code, do:
VB Code:
Dim X As Long
Dim Y As Long
TempPic.Picture = Pic.Picture
For X = 0 To Pic.ScaleWidth
For Y = 0 To Pic.ScaleHeight
SetPixel Pic.hDC, X, Y, GetPixel(TempPic.hDC, Pic.ScaleWidth - X, Pic.ScaleHeight - Y)
Next Y
Next X
Pic.Refresh
-
Jan 6th, 2003, 04:05 PM
#3
Good Ol' Platypus
The reason is that the pixel bits are actually flipped in memory, however it displays correctly when SetDIBits is used (I think). If it still isn't, you should first try the loading options, and if all else fails (I'm assuming a 2D array with datatype of BYTE):
Code:
dim x as long
dim y as long
dim tmpbyte as byte
for x = 0 to width * 3 - 1
for y = 0 to height - 1
tmpbyte = dib(x, y)
dib(x, y) = dib(x, height - y)
dib(x, height - y) = tmpbyte
next y
next x
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jan 6th, 2003, 05:12 PM
#4
cyborg: DIB stands for Device Independent Bitmap = (more or less) a bmp file.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 6th, 2003, 05:36 PM
#5
Thread Starter
Junior Member
how long will these take 2 flip?? its a 6 meg picture (2732x2732 pixels) i know its pretty instant in picture progs lol
would it be quicker 2 load it useing dib code?
-
Jan 7th, 2003, 07:22 AM
#6
Picture progs only flip it once (when loading it) and then simply blit the corrected version.
It's pretty fast to flip, but not so fast that you should do it everytime you draw the img.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 7th, 2003, 11:08 AM
#7
Thread Starter
Junior Member
when i said in progs i was refering 2 when the user clicks the flip button
i only need it flipped once (on load) so using a dib code to load would prob b faster, coz by the looks of those codes they do it line by line, its a 2732x2732 pixel image so it will take a wile i think, ill try them tonight when i get back fromwork to see ho fast or slow they are
thx for the help
-
Jan 7th, 2003, 02:54 PM
#8
You can either do it line by line or pixel by pixel. But line by line in effect comes down to pixel by pixel too.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 7th, 2003, 03:14 PM
#9
Thread Starter
Junior Member
i dont mind what the method is, just as long as its fast lol
-
Jan 8th, 2003, 12:53 PM
#10
Hyperactive Member
I use stretchblit to do flips passing in passing in a memorydc and manipulating the dest with. Make it dynamic and you can spin stuff pretty easily.
ex: stretchblit memdc(0)x,y,width-x,height,memdc(1) _ x2,y2,width2,height2,vbsrccopy
-
Jan 8th, 2003, 06:46 PM
#11
Thread Starter
Junior Member
cheers for all your help guys, i got it working now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|