Please, someone could tell me How can I implement Sepia tone in Language C?, In my project I´ve got to implement the code with Android NDK. I´ve found some examples and I must code with this:
outputRed = (inputRed * .393) + (inputGreen *.769) + (inputBlue * .189)
outputGreen = (inputRed * .349) + (inputGreen *.686) + (inputBlue * .168)
outputBlue = (inputRed * .272) + (inputGreen *.534) + (inputBlue * .131)
Sepia toning in C#
http://www.techques.com/question/1-4141150/Convert-bitmap-to-sepia-in-android
How could I implement this code above, but NDK C, please?
I really appreciate if someone can help me or give some tips.
Regards,
Carlos
It´s simple, I´ve got a final project and I need to implement a Android Camera app, so I need to convertir normal photo to Sepia tone, but in code native, it means in C. I´ve found some examples, but all that I find is in C# or ColorMatrix Class. There is an example:
https://bitbucket.org/steven_rudenko/colormatrix
I need to implement Sepia toning in C, but using Android NDK.
Regards,
Carlos
Related
I'm trying to import Google VR package to my Unity project.
The reticle looks much smaller than it's supposed to and I don't know why and how to fix it. I'm using unity 5.3.4 and I believe the Google VR version is v0.8.0
Here is a screen shot I took from the the demo scene
Thanks in advance.
In GoogleVR/Scripts/UI, open GvrReticle.cs and in UpdateDiameters() function
replace this code :
reticleInnerDiameter = Mathf.Lerp(reticleInnerDiameter, inner_diameter, Time.deltaTime * reticleGrowthSpeed);
reticleOuterDiameter = Mathf.Lerp(reticleOuterDiameter, outer_diameter, Time.deltaTime * reticleGrowthSpeed);
with these values or what ever that adjusts your device resolution :
reticleInnerDiameter = 0;
reticleOuterDiameter = 0.08726701;
for an Android Sequencer App, we gave a try to the Superpowered audio engine, which uses the Android NDK and C++. It's a very young project and there are some bugs in it, for example if a sample is too short, the buffers aren't cleared correctly, so I like to clear them by myself. For these, the memory is aligned this way:
bufferA = (float *)memalign(16, (buffersize + 16) * sizeof(float) * 2);
Because I'm a C++ beginner, I don't know how I could iterate through this pointer bufferA to overwrite its values.
Can anybody help? Thanks!
I have a requirement like this. Here is my home class snapshot.
It contains several shop shape. And for that I have used this code :
ArrayList<Point> points2 = new ArrayList<Point>();
points2.add(vertex.Get(20, 0));
points2.add(vertex.Get(44, 0));
points2.add(vertex.Get(44, 25));
points2.add(vertex.Get(20, 25));
Polygon view1 = new Polygon(context, points2, android.R.color.holo_orange_dark, R.color.background_light, floor != 0);
view1.setId(0);
views.add(view1);
addView(view1);
This is for static number of shapes.Now requirement is such that number of shapes will be dynamic.and for that i don't need to use same code as above.Client has told to implement Straight Skeleton Algorithm.
I googled about it and found some help for same algorithm implementation in core java.
Java library for creating straight skeleton?
This issue explains in java.I tried it out,that is totaly in core java.I need to implement it on android.and Never worked on such issue before.Need some help if some one have already implemented it on android.
Thanks
You should try this:
https://code.google.com/p/campskeleton/
From this answer:
Java library for creating straight skeleton?
I was surfing the net looking for a nice effect for turning pages on Android and there just doesn't seem to be one. Since I'm learning the platform it seemed like a nice thing to be able to do is this.
I managed to find a page here: http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html
- (void)deform
{
Vertex2f vi; // Current input vertex
Vertex3f v1; // First stage of the deformation
Vertex3f *vo; // Pointer to the finished vertex
CGFloat R, r, beta;
for (ushort ii = 0; ii < numVertices_; ii++)
{
// Get the current input vertex.
vi = inputMesh_[ii];
// Radius of the circle circumscribed by vertex (vi.x, vi.y) around A on the x-y plane
R = sqrt(vi.x * vi.x + pow(vi.y - A, 2));
// Now get the radius of the cone cross section intersected by our vertex in 3D space.
r = R * sin(theta);
// Angle subtended by arc |ST| on the cone cross section.
beta = asin(vi.x / R) / sin(theta);
// *** MAGIC!!! ***
v1.x = r * sin(beta);
v1.y = R + A - r * (1 - cos(beta)) * sin(theta);
v1.z = r * (1 - cos(beta)) * cos(theta);
// Apply a basic rotation transform around the y axis to rotate the curled page.
// These two steps could be combined through simple substitution, but are left
// separate to keep the math simple for debugging and illustrative purposes.
vo = &outputMesh_[ii];
vo->x = (v1.x * cos(rho) - v1.z * sin(rho));
vo->y = v1.y;
vo->z = (v1.x * sin(rho) + v1.z * cos(rho));
}
}
that gives an example (above) code for iPhone but I have no idea how I would go about implementing this on android. Could any of the Math gods out there please help me out with how I would go about implementing this in Android Java.
Is it possible using the native draw APIs, would I have to use openGL? Could I mimik the behaviour somehow?
Any help would be appreciated. Thanks.
****************EDIT**********************************************
I found a Bitmap Mesh example in the Android API demos: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.html
Maybe someone could help me out on an equation to simply fold the top right corner inward diagnally across the page to create a similar effect that I can later apply shadows to to gie it more depth?
I'm doing some experimenting on page curl effect on Android using OpenGL ES at the moment. It's quite a sketch actually but maybe gives some idea how to implement page curl for your needs. If you're interested in 3D page flip implementation that is.
As for the formula you're referring to - I tried it out and didn't like the result too much. I'd say it simply doesn't fit small screen very well and started to hack a more simple solution.
Code can be found here:
https://github.com/harism/android_page_curl/
While writing this I'm in the midst of deciding how to implement 'fake' soft shadows - and whether to create a proper application to show off this page curl effect. Also this is pretty much one of the very few OpenGL implementations I've ever done and shouldn't be taken too much as a proper example.
I just created a open source project which features a page curl simulation in 2D using the native canvas: https://github.com/moritz-wundke/android-page-curl
I'm still working on it to add adapters and such to make it usable as a standalone view.
EDIT: Links updated.
EDIT: Missing files has been pushed to repo.
I'm pretty sure, that you'd have to use OpenGL for a nice effect. The basic UI framework's capabilities are quite limited, you can only do basic transformations (alpha, translate, rotate) on Views using animations.
Tho it might be possible to mimic something like that in 2D using a FrameLayout, and a custom View in it.
Does Android have a similar method to the iPhone AVAudioPlayer's averagePowerForChannel?
I want to get an average reading of the amplitude of as a value.
I don't think there is a built-in function but you can calculate it yourself.
To do this, calculate the root-mean-square average of continuous samples.
rms = sqrt((sample0^2 + sample1^2 + sample2^2 + sample3^2) / numberOfSamples)
The following links should be helpful to you as they contain the full source code to two excellent Android sound related projects.
Ringdroid
Rehearsal Assistant