rathinagiri
Member
I am working on a project of showing 3D images where we have two images one for left eye and another for right eye. For those who don't have VR devices, I am planning the show the image as Anaglyph images, where Right eye Red is replaced with Left Eye Red.
It works great. However, the For Next loop which goes through each pixel to get RGB from Left image and set RGB in Right Image takes minimum 10 seconds for an image of 1920 by 1080 pixels.
Any suggestions please?
It works great. However, the For Next loop which goes through each pixel to get RGB from Left image and set RGB in Right Image takes minimum 10 seconds for an image of 1920 by 1080 pixels.
Any suggestions please?
B4X:
Dim Bc As BitmapCreator
Dim bcleft As BitmapCreator
Dim bcright As BitmapCreator
Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets, "fractal0001.jpg")
Dim nWidth As Int
Dim nHalf As Int
Dim r As B4XRect
Dim i As Int = 0
Dim j As Int = 0
Dim leftrgb As ARGBColor
Dim rightrgb As ARGBColor
Dim nHeight As Int = bmp.Height
nWidth = bmp.Width
nHalf = nWidth / 2
Bc.Initialize( nHalf, nHeight )
bcleft.Initialize(nHalf, nHeight )
bcright.Initialize( nHalf, nHeight)
Dim right1 As BCBrush = Bc.CreateBrushFromBitmap(bmp.Crop(nHalf, 0, nHalf, nHeight))
Dim left1 As BCBrush = Bc.CreateBrushFromBitmap(bmp.Crop(0, 0, nHalf, nHeight))
r.Initialize(0,0,nHalf, nHeight )
bcleft.DrawRect2( r, left1, True,1)
bcright.DrawRect2( r, right1, True, 1 )
For i = 0 To nHalf - 1
For j = 0 To nHeight - 1
bcleft.GetARGB( i,j,leftrgb )
bcright.GetARGB( i, j, rightrgb)
rightrgb.r = leftrgb.r
bcright.SetARGB( i, j, rightrgb )
Next
Next
Return FillImageToView( bcright.Bitmap,Root)