12.1 Create an Instance of a Bitmap

The CreateBitmap method generates a PRIM_BMP instance.

This can be useful for converting Blobs into images and processing files selected using the FilePicker.

If executing in the browser and a Filename is assigned to the method, the actual load of a file to create a bitmap is asynchronous. The Loaded event is used to determine when this is complete.

This example loads a BLOB field into a PRIM_IMAG to display on the Web Page:

Define_Com Class(#PRIM_IMAG) Name(#MyImage) Displayposition(5) Left(191) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(6) Height(788) Width(1003)

Mthroutine Name(LoadImage)

 

Define_Com Class(#MyServerMod.GetImage) Name(#GetImage)

 

#GetImage.ExecuteAsync( #xEmployeeImage )

 

Evtroutine Handling(#GetImage.Completed)

 

  #MyImage.Image <= #sys_appln.CreateBitmap( #xEmployeeImage )

 

Endroutine

 

Endroutine

 

This example allows for the selection of an image and shows the selected image on the Web Page:

Begin_Com Role(*EXTENDS #PRIM_WEB) Layoutmanager(#TableLayout1)

 

Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)

Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1) Width(185) Units(Pixels)

Define_Com Class(#PRIM_TBLO.Column) Name(#Column2) Displayposition(2) Parent(#TableLayout1) Width(1.7)

Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1)

Define_Com Class(#PRIM_TBLO.Row) Name(#Row2) Displayposition(2) Parent(#TableLayout1) Height(50) Units(Pixels)

Define_Com Class(#PRIM_TBLO.Item) Name(#FilePicker1Item1) Alignment(TopCenter) Column(#Column1) Manage(#FilePicker) Parent(#TableLayout1) Row(#Row1) Sizing(None) Margintop(6)

Define_Com Class(#PRIM_TBLO.Item) Name(#Image1Item1) Column(#Column2) Manage(#Image) Parent(#TableLayout1) Row(#Row1) Margintop(6) Marginright(6) Marginbottom(6) Marginleft(6)

Define_Com Class(#PRIM_TBLO.Item) Name(#Label1Item1) Alignment(BottomCenter) Column(#Column2) Manage(#Filename) Parent(#TableLayout1) Row(#Row2) Sizing(FitToWidth) Marginbottom(12) Marginright(12) Marginleft(12)

 

Define_Com Class(#PRIM_WEB.FilePicker) Name(#FilePicker) Displayposition(2) Ellipses(Word) Height(56) Left(8) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(6) Verticalalignment(Center) Width(169) Image(#xImageCamera32) Caption('Select an Image') Marginleft(8) Themedrawstyle('PushButton')

Define_Com Class(#PRIM_IMAG) Name(#Image) Displayposition(3) Left(191) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(6) Height(738) Width(1003)

Define_Com Class(#PRIM_LABL) Name(#Filename) Displayposition(1) Ellipses(Word) Height(55) Left(197) Parent(#COM_OWNER) Tabposition(3) Tabstop(False) Top(733) Verticalalignment(Center) Width(991) Alignment(Center) Themedrawstyle('Heading1')

 

Evtroutine Handling(#FilePicker.FileSelected) File(#File)

 

* Image loading is asynchronous.  All we can do here is make the image instance

#Image.Image <= #sys_appln.Createbitmap( #File.blob )

 

#Filename := #File.blob

 

Endroutine

 

End_Com