Platforms to show: All Mac Windows Linux Cross-Platform

/Images/LargePicture/Windows Picture with Alpha Test


Required plugins for this example: MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/LargePicture/Windows Picture with Alpha Test

This example is the version from Mon, 22th Nov 2015.

Project "Windows Picture with Alpha Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
End Control
Control Canvas3 Inherits Canvas
ControlInstance Canvas3 Inherits Canvas
End Control
Control Canvas4 Inherits Canvas
ControlInstance Canvas4 Inherits Canvas
End Control
Control Canvas5 Inherits Canvas
ControlInstance Canvas5 Inherits Canvas
End Control
Control Canvas6 Inherits Canvas
ControlInstance Canvas6 Inherits Canvas
End Control
Control Canvas7 Inherits Canvas
ControlInstance Canvas7 Inherits Canvas
End Control
Control Canvas8 Inherits Canvas
ControlInstance Canvas8 Inherits Canvas
End Control
Control Canvas9 Inherits Canvas
ControlInstance Canvas9 Inherits Canvas
End Control
Control Canvas10 Inherits Canvas
ControlInstance Canvas10 Inherits Canvas
End Control
EventHandler Sub Open() ' testing PictureMBS byte order app.UseGDIPlus = true test1 test2 End EventHandler
Sub test1() const w = 100 const h = 100 // make picture with some color dim p as new picture(w,h) dim r as RGBSurface = p.RGBSurface for y as integer = 0 to h-1 for x as integer = 0 to w-1 r.Pixel(x,y) = &cFF80bb99 next next canvas1.Backdrop = p // now make PictureMBS based on above picture dim pSrc as new PictureMBS(p,p.HasAlphaChannel) // and one based on MemoryBlock dim data as new MemoryBlock(w*h*4) dim pDest as new PictureMBS(data,w,h,PictureMBS.ImageFormatBGRA,w*4) canvas2.Backdrop = pSrc.CopyPicture // copy pixels call pDest.copyPixels(pSrc) // show with and without mask dim p2 as picture = pDest.CopyPicture dim p3 as Picture = pDest.CopyPictureWithMask // using alpha as mask will cause trouble! canvas3.Backdrop = p2 canvas4.Backdrop = p3 // now copy in a new picture dim q as new Picture(w,h) dim temp as new PictureMBS(q,q.HasAlphaChannel) call temp.copyPixels(pDest) temp = nil canvas5.Backdrop = q // Warning: Picture from Xojo may be premultiplied. // Using premultiplied image and show it as an unpremultiplied (what we do above) will show a darker picture. End Sub
Sub test2() // now test without alpha const w = 100 const h = 100 // make picture with some color dim p as new picture(w,h) dim r as RGBSurface = p.RGBSurface for y as integer = 0 to h-1 for x as integer = 0 to w-1 r.Pixel(x,y) = &cFF80bb next next canvas6.Backdrop = p // now make PictureMBS based on above picture dim pSrc as new PictureMBS(p,p.HasAlphaChannel) // and one based on MemoryBlock dim data as new MemoryBlock(w*h*4) dim pDest as new PictureMBS(data,w,h,PictureMBS.ImageFormatBGRA,w*4) canvas7.Backdrop = pSrc.CopyPicture // copy pixels call pDest.copyPixels(pSrc) // show with and without mask dim p2 as picture = pDest.CopyPicture dim p3 as Picture = pDest.CopyPictureWithMask // using alpha as mask will cause trouble! canvas8.Backdrop = p2 canvas9.Backdrop = p3 // now copy in a new picture dim q as new Picture(w,h) dim temp as new PictureMBS(q,q.HasAlphaChannel) call temp.copyPixels(pDest) temp = nil canvas10.Backdrop = q // Warning: Picture from Xojo may be premultiplied. // Using premultiplied image and show it as an unpremultiplied (what we do above) will show a darker picture. End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

The items on this page are in the following plugins: MBS Images Plugin.


The biggest plugin in space...