Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Contributor
Posts: 16
Registered: ‎01-27-2013
My Device: blackberry9360
My Carrier: docomo
Accepted Solution

I want to generate a png lightest

Is there a better way to make something in the java of PNG 8, Truecolour: BitDepth byte from [] or bitmap, the base64 data?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I want to generate a png lightest

Sorry not clear what the question is here.  Can you please explain again?  Perhaps explain what you are trying to do?

Contributor
Posts: 16
Registered: ‎01-27-2013
My Device: blackberry9360
My Carrier: docomo

Re: I want to generate a png lightest

I'm looking for a way to avoid it because there is a memory limit during processing capacity that can save png.
If Naose encoded into something lighter by changing the colourtype of png, where they came up with is that it might be somehow.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I want to generate a png lightest

Still not clear to me, but perhaps I can ask some questions to clarify.

 

By lighter, do you mean

a) smaller,

b) lighter in color (not so dark)

c) simpler to process (does not take up as much processing capacity). 

I think you mean smaller, just want to be sure.

 

How did you get this image?

 

What are you trying to do with this image?

 

You say "there is a memory limit during processing"

What is happening that makes you think there is a memory limit?  What is this limit - what size image will work OK?

 

What is "Naose encoded"?

Contributor
Posts: 16
Registered: ‎01-27-2013
My Device: blackberry9360
My Carrier: docomo

Re: I want to generate a png lightest

mr.peter_strange

 

By lighter, do you mean

a) smaller

 

this is japanese site

http://blog.livedoor.jp/imaya_js/archives/6152700.html

 

I'm looking for a way to do the java that you are doing in javascript on this site.

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I want to generate a png lightest

Can you answer my other questions, especially:

 

1) How did you get this image?

 

2) You say "there is a memory limit during processing"

What is happening that makes you think there is a memory limit?  What is this limit - what size image will work OK?

 

However it seems you are trying to create an image editing package on the BlackBerry.  Sounds like fun.  Sorry I am probably not going to be much help here with respect to this processing.  But if I was trying to do something like this, then I would process the raw image as an ARGB file, and then use on of the standard encoding methods to convert it to png or what else I wanted to convert it to.  Have a look at the EncodedImage class and its various subclasses. 

Contributor
Posts: 16
Registered: ‎01-27-2013
My Device: blackberry9360
My Carrier: docomo

Re: I want to generate a png lightest

1) How did you get this image?

i used webview by javascript.

 

this method.

"document.getElementsByTagName('canvas')[0].getContext('2d').toDataURL();"

 

2) You say "there is a memory limit during processing"

What is happening that makes you think there is a memory limit?  What is this limit - what size image will work OK?

 

I am getting in DataURL the canvas data in javascript in webview.
Size is 480 × 320.

If you get the base64 data by processing black and white, can be saved.
But, you can not when you try to save by getting DataURL by the processing brightness and number of colors, such as unsharp mask such increase.

 

As ARGB file, file size or is smaller than using the EncodedImage class from bitmap Treatment?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I want to generate a png lightest

[ Edited ]

Sorry, I appreciate that English is probably not your first language, but what you are saying is not 100% clear, so please understand when I try to clarify what you are asking.  It is better that I make sure I understand exactly what you are asking rather than try to answer what I think you are asking and get it wrong and confuse everyone....

 

What do you get as a result of this?

"document.getElementsByTagName('canvas')[0].getContext('2d').toDataURL();"

 

I presume that it is a URL, and you have to download this URL to get an image.  But I'm not clear.  So please can you explain how this processing works in detail.

 

"If you get the base64 data by processing black and white, can be saved."

What do you mean by "can be saved".  Saved where?  By what? 

 

How do you perform this processing to a black and white Base 64 encoded image?

Contributor
Posts: 16
Registered: ‎01-27-2013
My Device: blackberry9360
My Carrier: docomo

Re: I want to generate a png lightest

>What do you get as a result of this?

>"document.getElementsByTagName('canvas')[0].getContext('2d').toDataURL();"

 

this result

data:image/png;base64,*******

***** A string of base64 data.

 

Sample site

http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file

 

I wrote and saved, but aim to be when it comes to state that you can retrieve the image.

 

>How do you perform this processing to a black and white Base 64 encoded image?

 

When an image is displayed in the canvas tag out you can manipulate the value of RGB.
You change the value using it.

 

Sample site
http://www.ajaxblender.com/howto-convert-image-to-grayscale-using-javascript.html

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: I want to generate a png lightest

OK, I think I get it now.

 

You do effectively the same thing in Java.

 

Step 1, you need to convert the Base64 image to bytes

Use your own code or Base64InputStream.

 

Step 2, create Bitmap from this

Use Bitmap.createImageFromPNG, or Bitmap.createImageFromBytes

 

Step 3, extract the pixels

use <bitmap>.getARGB(..)

 

Step 4, process the ARGB

do whatever processing you want to do on each pixel - for example, convert to black and white

 

Step 5, set this back into a Bitmap

use <bitmap>.setARGB(..)

 

Now you can process the Bitmap as you require.

 

Hope this makes sense.