Sending java bitmap object to native classes for image processing - android-ndk

I want to design an image filter app. I've searched a lot but found nothing on how to pass java bitmap to c/c++ and then retrieve at native side and apply a basic image filter and return the result to java again to display it on ImageView. Any help is appreciated

Check the NDK Bitmap plasma sample, it shows how to do exactly that.
https://github.com/googlesamples/android-ndk/tree/master/bitmap-plasma

Related

how to convert the 3D object file(.obj) into 2D image(.png,.jpeg) using vtk and qt (c++)

In my project I have an object file. I need to convert the object file into an image. Can anyone help me with the code so that I can convert to an image. I am using VTK, qt and c++.
It sounds like you want to render an OBJ to an image. You can look at the Screenshot example to see how to do that:
https://lorensen.github.io/VTKExamples/site/Cxx/Utilities/Screenshot/
You probably have to set up the camera to get the viewpoint you want.

Can not assigned a bitmap object to QR code image returning from encoder

I installed Xamarin studio and trying to use System.Drawing frame work but it is not working. The reason I want this framework is to be able to define a Bitmap object. This bitmap object is assigned to a qr code image. Can anyone help me on how i can assigned an image to bitmap since i can not use bitmap in xamarin studio framework.
What i wanna do is as follows:
//create a qr code
QRCodeEncoder encoder = new QRCodeEncoder();
// Assign a bitmap image to the encoder since the encoder.encode returns bitmap image
Bitmap img = encoder.Encode("http://www.monkeywow.com");
// save the image in to images folder
img.save("www.monkeywow.com/images/imp.jpg", ImageFormat.jpg);
The problem is I can not use Bitmap img since i can not import System.Drawing into Xamarin.
I tried that and did not work. Since the encoder returns bitmap, i do not know how to obtain the image so i can save it where ever i want.
To display an image on screen, use UIImage. For working with low level bitmaps, use the CoreImage framework.
http://docs.xamarin.com/guides/ios/application_fundamentals/working_with_images/
http://docs.xamarin.com/recipes/ios/media/coreimage/
Xamarin.iOS includes a few System.Drawing types, e.g. Rectangle[F], Point[F] and Size[F], inside monotouch.dll to ease code sharing between (cross platform) projects.
However the System.Drawing.dll assembly itself is not part of the mobile profile that ships with Xamarin.iOS.
Like #Jason mentioned are several, native, ways you can do graphics on iOS (OpenGL would be another one).
Another option is to use the code from https://github.com/mono/sysdrawing-coregraphics which offers a partial System.Drawing API on top of CoreGraphics.

Images in J2me Lwuit

I have developed an LWUIT app. I have two types of images dispayed in the app. One coming from server side that need to displayed (like a photo posted and saved to server side) and one packaged in my jar and displayed mainly as icons (like a music icon, loading animation gif etc). I need to display all images according to the sreen size and resolution. The first kind is displayed by taking the screen display height and width and then use scale method and show a scaled version of the image. But however I have no idea how to show the second kind. i.e. icons. Example, my loading image looks good in most of the phones but for some phones like samsung, it looks blurred and over-sized. How to do this. My basic idea is to keep 3 types of images of icons like icon_width_lowXheight_low.png, icon_width_mediumXheight_medium.png and image_width_highXheight_high.png and show it based on the screen size. Please let me know the bets way to achieve this?
Thanks,
Parvathy
You should use MultiImages which were added in LWUIT 1.5. I don't have a link for this in LWUIT but our work in Codename One is pretty close to this so check out the How Do I? on multi images (and I suggest migration to Codename One regardless).
I think that you will need to use this
Image i = Image.createImage("your image path here");
i = i.scaled(widthValue, heightValue);
And put this values in relation to the Display.getInstance().getDisplayHeight() and Display.getInstance().getDisplayWidth()
Right?

Images do not show up when I run my app on iOS device

I have images titled like so in my app:
image~iPhone.png
image#2x~iPhone.png
In interface builder I am loading image.png into my UIImageView. I also programatically load some images into a different view using imageWithContentsOfFile. The images all load fine when I run in the simulator but I get no images when I run on the device. If I use the full name of the image in interface builder it works but I want iOS to distinguish between high res and lower res. I have tried a lot of different things but can't figure this out. I see this error in the debugger as well:
Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.mycompany.myproject"
Xcode 4
Deployment Target 4.1
Base SDK 4.3
Thanks for any help.
Ok...so after much experimenting I got it working.
I had two images named:
image#2x~iPhone.png
image~iPhone.png
and I was trying to load them using IB or imageWithContentsOfFile using
image.png
This worked fine in the simulator but not on my device. I just got a blank white screen where the image should be.
I finally renamed the high resolution image to:
image~iPhone#2x.png
Moving the '#2x' modifier after the device modifier(~iPhone) when referencing my images allowed it to work the way I understood that it should from reading Apple's docs. I was under the impression that you didn't need to include the device modifier when referencing images but I had to.
To sum up, I am now using
- image~iPhone.png
to reference my images in IB and programatically for some images. I now get iOS recognizing that I am on a retina screen and loading the #2x images accordingly. So the #2x modifier had to go at the end and the ~iPhone modifier had to be included in the name of the '.png'.
That is what worked for me. Hope it helps someone else. Note that I am only building my app for iOS4.1 and above so there might be some issues with this if you are supporting previous version.
iOS does not automatically pick the right image for the device like that. You are going to have to write code to check which device it is, and set the image by full name.
e.g. if ([[UIScreen mainScreen] scale] == 2) // set hi res image
Or, you can just use the same image in both, and set the content mode to scale to fill. It will look the same.
EDIT: Try writing either ~iphone (lowercase), or just don't write ~iPhone at all on the file name. If your app is not universal, then writing the ~iphone suffix is completely pointless.
iOS file system is case sensitive and device modifiers should be lowercase, it should be
image~iphone.png
image#2x~iphone.png
The #2x comes before the device modifier.
See the resource programming guide

How to set Legend with Open Flash Chart 2 graphic using Open source Java API - JOFC?

I have a Seam 2.2 app running under JBoss5.1. In this application I have successfully developed some Graphics using Java Open Flash Chart, which is a Java API for Open Flash Chart.
Now I would like to add a X and Y legend like this one.
Well I have a graphic which is rendering properly and than I try to set X Label using:
...
chart.setXLegend(new Text("Legenda X"));
But than instead of showing the legend it corrupts something which causes the graphic to renders completely blank.
This is the generated JSon when the graphics renders correctly.
{"y_axis":{"min":388,"max":866,"steps":20},"title":{"text":"Gráfico de gasto mensal com Combustível"},"bg_colour":"#FFFFFF","is_decimal_separator_comma":0,"elements":[{"values":[{"tip":"R$:610.0\n05/2010","top":610},{"tip":"R$:488.0\n06/2010","top":488},{"tip":"R$:634.57\n07/2010","top":634.57},{"tip":"R$:766.0\n08/2010","top":766},{"tip":"R$:396.0\n09/2010","top":396},{"tip":"R$:610.0\n10/2010","top":610}],"type":"bar"}],"num_decimals":2,"is_fixed_num_decimals_forced":0,"x_axis":{"labels":{"labels":["05/2010","06/2010","07/2010","08/2010","09/2010","10/2010"]}},"is_thousand_separator_disabled":0}
I took a deeply look at it and turns out that whenever I try to add the x legend with the code fragment showed above the JSon is actually NOT generated by JOFC.
I could not find much useful documentation on JOFC on the web and the API itself is not very well documented, so I am completely lost on trying to add this simple x label, which should be the easiest part :( . Any Ideas on that.
An update:
Now I just have downloaded JOFC source code and will take a look at this.
It looks like there's an open issue on the JOFC page: http://code.google.com/p/jofc2/issues/detail?id=29
It suggests a workaround of calling the function like:
chart.setXLegend(new Text("Legenda X", Text.TEXT_ALIGN_CENTER))
I would try with Open Flash Grapix, it is easier to use, and just sets parameters on FlashVars.
Open Flash Grapix

Resources