image help
Posted: Thu Apr 24, 2008 1:29 pm
how do i flip an image vertically and save it, any help?
Code: Select all
ProcedureDLL imgm_MirrorImageY(image)
; Mirrors an image around the Y-axis
Width = ImageWidth(image)
Height = ImageHeight(image)
hdc = StartDrawing(ImageOutput(image))
StretchBlt_(hdc,0,Height,Width,-Height,hdc,0,0,Width,Height, #SRCCOPY) ;
StopDrawing()
EndProcedure
Code: Select all
ProcedureDLL imgm_MirrorImageX(image)
; Mirrors an image around the X-axis
Width = ImageWidth(image)
Height = ImageHeight(image)
hdc = StartDrawing(ImageOutput(image))
StretchBlt_(hdc,Width,0,-Width,Height,hdc,0,0,Width,Height, #SRCCOPY) ;
StopDrawing()
EndProcedure
For loading and saving, check out the purebasic manual, it has some examplesand save it,
Code: Select all
LoadImage(1, "bm2.bmp")
ProcedureDLL imgm_MirrorImageY(image)
; Mirrors an image around the Y-axis
Width = ImageWidth(image)
Height = ImageHeight(image)
hdc = StartDrawing(ImageOutput(image))
StretchBlt_(hdc,0,Height,Width,-Height,hdc,0,0,Width,Height, #SRCCOPY) ;
StopDrawing()
EndProcedure
If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Repaint
;Draw the original image.
StartDrawing(WindowOutput(0))
DrawImage(ImageID(1), 0, 0)
StopDrawing()
;Draw the original image.
imgm_MirrorImageY(1)
StartDrawing(WindowOutput(0))
DrawImage(ImageID(1), 100, 0)
StopDrawing()
EndIf
Until EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
EndIf
i did tell him the nice way first. But oh well:Fluid Byte wrote:RTFM would help.
In srods example, saveimage(1,"test.bmp")Result = SaveImage(#Image, FileName$ [, ImagePlugin [, Flags]])
Saves the specified #Image to disk. By default, the saved image will be in 24bit BMP format. If function fails, 0 is returned, else all is fine. 'ImagePlugin' is an optional parameter and can be one of the following constant:
#PB_ImagePlugin_BMP : Save the image in BMP.
#PB_ImagePlugin_JPEG : Save the image in JPEG (the function UseJPEGImageEncoder() must be used)
#PB_ImagePlugin_PNG : Save the image in PNG (the function UsePNGImageEncoder() must be used)
'Flags' is an optional parameter depending of the plugin used. For now, only the quality setting is supported: a number from 0 (worste quality) to 10 (maximum quality). Only the JPEG plugin currently support it (default quality is set to '7' if no flags are specified with the JPEG encoder).
come on, you got nearly 200 posts, you should be able to read the manual by now!thefool wrote: For loading and saving, check out the purebasic manual, it has some examples