Forum Replies Created
-
AuthorPosts
-
Amazing!
Windows 10, intel graphics
before 90 fps
after 220 fps
Android, Samsung J5 2016
before 30 fps
after 120 fps
now this can be actually used
Jesse, yes, of course when i make this change i get the original problem.
It was only done to demonstarte the perfomance penalty. And the question why drawing into image convas is so much slower.
Thank you Jesse.
I ran your code and it works as needed.I tested perfomance and compared.
Your code run at 90 fps
My code runs at 350 fps
If i put
cnvs=canvas
befor
cnvs.Clear(New Color(0,0,0,0))
(basically drawing again everything into main canvas instead of image)
I get 300 fps from your code
So, drawing into canvas attached to an image has huge perfomance penalty.
Interesting, however, than it does not really matter how much i draw into that image canvas. If i have flush or clear
i get stable 90 fps.
I wonder why so much perfomance penalty and why it is pretty constant and independat of how much is drawing into it.
alas, this is not it because if te green circle is for example 0x88 then when blended with itself using additive blending it gets 0xff color in green channel, which is is not the original 0x88
i miss normal bitwise OR/AND/XOR blending
Got it. But what exactly premultiplying alpha does on pixmap? It does not seem to modify pixmap data at all. Since pmAlpha is using DESTINATION RGB to calculate resulting pixel color then it seems like premultiplying alpha is just some kind of flag/parameter which is used by device rendering part. And it seems to work globaly, not locally for one pixmap.
At least in all examples i saw the pmAlpha is set for d3d globally.
Thank you for explaning the badk work with image data. This is a mess, but probably there is not better way for now at least.
I understood that pixmap is the basic object for images and that the thing i need. Image is kinda convinience wrapper.
As you see i am using pixmap load i the example i did.
But i dont understand how pmAlpha argument for pixmap.load works.
If i set it to False i don’t get any alpha at all. So, basically it is pmAlpha=True or no alpha at all.
Did i get it right?
Okay, i have done it. See code below. HOWEVER one thing i don’t understand. if ALPHA channel is ZERO i can still the color. To fully hide pixel i need to set ALPHA to zero and RGB to zero also. This i don’t understand.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374Namespace pmtest#Import "<std>"#Import "<mojo>"#Import "assets/"Using std..Using mojo..Class MyWindow Extends WindowField pixmap:std.graphics.PixmapField image:ImageField k:IntField colors:UInt[]Field currentColor:Color = Color.WhiteMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )colors=New UInt[5]colors[0]=$FF0000FFcolors[1]=$FF00FF00colors[2]=$FFFF0000colors[3]=$FF00FFFFcolors[4]=$FFFFFF00pixmap= std.graphics.Pixmap.Load("asset::test.png",std.graphics.PixelFormat.RGBA32,True)Local p:UInt Ptrp=Cast<UInt Ptr>(pixmap.Data)For Local i:Int=0 To 100*100' ABGRIf p[i]=$FF000000 Thenp[i]=colors[0]EndifNextimage = New Image(pixmap)EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()If Keyboard.KeyPressed(Key.Space)k=k+1If k>4 Then k=0Local p:UInt Ptrp=Cast<UInt Ptr>(pixmap.Data)For Local i:Int=0 To 100*100' if anythung non transparentIf p[i] & $FF000000 Thenp[i]=colors[k]EndifNextimage = New Image(pixmap)End Ifcanvas.Clear(Color.Grey)canvas.Color=Color.Bluecanvas.DrawOval(100,100,100,50)canvas.Color=Color.Whitecanvas.DrawImage(image,100,100)EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndAttachments:
aha, so i neex pixelmap, not image
pixelmap has load method which load from png and save which saves to png
that’s very good, i will play with it
Aha, found this in image class description
-
<li class=”mx2docs”>Color – when rendering an image to a canvas, this property is multiplied by the current canvas color and the result is multiplied by actual image pixel colors to achieve the final color to be rendered.
So, color does not do it.
I guess i need a way to directly manipulate pixels in image or on canvas in ARGB fomat.
I don’t see anyt ReadPixels/WritePixels in mojo2 for images and buffers.
Is it possible?
Thank you
I tried mojotest app from bananas
did this:
image=Image.Load( “asset::RedbrushAlpha.png” ) image=Image.Load( “asset::RedbrushAlpha.png” ) image.Color=Color.Grey
The result is strange. Seems .color does not replacem pixel colors, but mixes with pixels in image.
See attached file.
Also, this way i do not have any way to choose what color to replace. But it is secondary task.
Attachments:
And final. The error was about min SDK version. The default gradle.build has level 10, while some calls are from level 12. I put level 12 into min version and now it build without error. But still. very very manual.
-
AuthorPosts

