flip image horizontally
flip image horizontally
Hello,
I would like to flip the image horizontally on OSX and Windows
As an example I want a helmet is photographed by the left side, so pointing to the left
then points to the right so than when it is photographed by the right
I have been looking for a while in all the forums but found nothing
can anyone help me?
when it comes it should not be Windows-specific because I'm just about a program
writing under Windows and OSX
many Greetings
I would like to flip the image horizontally on OSX and Windows
As an example I want a helmet is photographed by the left side, so pointing to the left
then points to the right so than when it is photographed by the right
I have been looking for a while in all the forums but found nothing
can anyone help me?
when it comes it should not be Windows-specific because I'm just about a program
writing under Windows and OSX
many Greetings
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: flip image horizontally
What you are looking for is this really excellent code by Luis: http://www.purebasic.fr/english/viewtop ... 12&t=38975
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: flip image horizontally
@chuf,
You might find this excellent code interesting, too:
http://www.purebasic.fr/english/viewtop ... 28#p445225
You might find this excellent code interesting, too:
http://www.purebasic.fr/english/viewtop ... 28#p445225
DE AA EB
Re: flip image horizontally
many thanks for the answer, im using Luis code the first test by OS X Yosemite works very fine, my next test is by windows
Re: flip image horizontally
Hi,
try this too:
It's short in code and I hope it's fast enough.
Since it uses only PB internal commands, it is crossplatform.
Bernd
try this too:
Code: Select all
UseJPEGImageDecoder()
UseJPEGImageEncoder()
Filename$ = OpenFileRequester("Choose an image", "", "JPG|*.jpg", 0)
If Len(Filename$)
OrgImg = LoadImage(#PB_Any, Filename$)
If OrgImg
Width = ImageWidth(OrgImg)
Height = ImageHeight(OrgImg)
NewImg = CreateImage(#PB_Any, Width, Height)
If NewImg
If StartDrawing(ImageOutput(NewImg))
For x = Width - 1 To 0 Step -1
StripeImg = GrabImage(OrgImg, #PB_Any, x, 0, 1, Height)
If StripeImg
DrawImage(ImageID(StripeImg), Width - x - 1, 0)
FreeImage(StripeImg)
EndIf
Next x
StopDrawing()
SaveImage(NewImg, Filename$ + ".mirrored.jpg", #PB_ImagePlugin_JPEG)
EndIf
FreeImage(NewImg)
EndIf
FreeImage(OrgImg)
EndIf
EndIf
Since it uses only PB internal commands, it is crossplatform.
Bernd
Re: flip image horizontally
Hi Bernd, this is a very fine short code, i am have testing this with a .png file by UsePNGImageDecoder()
one problem by this solution is: the picture has a black background color can you help me to fix this?
i love your short code
Best Regards
one problem by this solution is: the picture has a black background color can you help me to fix this?
i love your short code
Best Regards
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: flip image horizontally
You just need two quick changes to support PNG transparency:
Code: Select all
UsePNGImageDecoder()
UsePNGImageEncoder()
Filename$ = OpenFileRequester("Choose an image", "", "PNG|*.png", 0)
If Len(Filename$)
OrgImg = LoadImage(#PB_Any, Filename$)
If OrgImg
Width = ImageWidth(OrgImg)
Height = ImageHeight(OrgImg)
NewImg = CreateImage(#PB_Any, Width, Height, 32, #PB_Image_Transparent) ; <---------------- Changed line
If NewImg
If StartDrawing(ImageOutput(NewImg))
For x = Width - 1 To 0 Step -1
StripeImg = GrabImage(OrgImg, #PB_Any, x, 0, 1, Height)
If StripeImg
DrawAlphaImage(ImageID(StripeImg), Width - x - 1, 0) ; <--------------------Changed line
FreeImage(StripeImg)
EndIf
Next x
StopDrawing()
SaveImage(NewImg, Filename$ + ".mirrored.png", #PB_ImagePlugin_JPEG)
EndIf
FreeImage(NewImg)
EndIf
FreeImage(OrgImg)
EndIf
EndIf
BERESHEIT
Re: flip image horizontally
Hi,
netmaestro's code should fix this, else you can specify a backgroundcolor at CreateImage().
netmaestro made a typo:
use
Bernd
netmaestro's code should fix this, else you can specify a backgroundcolor at CreateImage().
netmaestro made a typo:
use
Code: Select all
SaveImage(NewImg, Filename$ + ".mirrored.png", #PB_ImagePlugin_PNG)
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: flip image horizontally
Ha, I was checking results with the LibraryViewer so I didn't notice the oversight. One more failure to attend to detail to go with the other 117 for today! Thanks inf
BERESHEIT
Re: flip image horizontally
many many Thanks now works fine for me