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: ‎07-30-2012
My Device: None
My Carrier: Proximus
Accepted Solution

Merge two EncodedImages next to eachother

Hi,

 

I've been looking around on the forum and I'm wondering if you can have two EncodedImages, apply the getData() method from both and combine it into one EncodedImage without using Bitmap. I saw different posts but it stays inclear to me.

		byte[] array2 = image1.getData(); 
		
		byte[] array1 = image2.getData();
		byte[] combined = new byte[array1.length + array2.length];
		for (int i = 0; i < combined.length; ++i)
		{
		    combined[i] = i < array1.length ? array1[i] : array2[i - array1.length];
		    
		}
		map = EncodedImage.createEncodedImage(combined, 0, combined.length);

 

Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Merge two EncodedImages next to eachother

[ Edited ]

getData() will return encoded image data (for PNG it wil return PNG data content, not pixels). I would suggest to create offscreen Graphics object, use one of the ROP operations (sample on canvas, use this as guideline in search for ROP in Graphics object) and perform ROP action with another bitmap.

 

Hope this will help you.

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Contributor
Posts: 16
Registered: ‎07-30-2012
My Device: None
My Carrier: Proximus

Re: Merge two EncodedImages next to eachother

[ Edited ]

The resolution of the final bitmap will be too big and I'll get an error.. and I need a bigger resolution, that is why I'm working with images..

Will your solution work then?

Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Merge two EncodedImages next to eachother

Do you need full resolution of this image? If you are merging it only for display resize your source image. If you need full image resolution you will have to work on smaller chunks of source image (stripes) and encode them on your own.

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications
Contributor
Posts: 16
Registered: ‎07-30-2012
My Device: None
My Carrier: Proximus

Re: Merge two EncodedImages next to eachother

first of all thanks

what do you mean smaller chunks? divide the image? I already did that.. now I'm looking for something to merge the divided images back to 1.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Merge two EncodedImages next to eachother

Could you please mark as Solved the Threads that you have started that precede this Thread.  This indicates that you have reached a conclusion on the Thread and are not going to progress the problem any more.  Instructions are in the Help link near the top of the screen. 

Developer
Posts: 192
Registered: ‎09-23-2009
My Device: 9860/PlayBook/Dev Alpha
My Carrier: Plus GSM

Re: Merge two EncodedImages next to eachother

There is no built in support for merging many encoded images into one, it looks like you should encode them on your own using some java library which supports jpg or png files. Maybe digging into jpg file format will show you how to join multiple stripes into one file.

Found my post helpfull? Like it! It solves your trouble? Help others and accept it as solution. Search before asking.
My apps: Secret Cod3s | Should my tablet be banned?
--
Jakub Nietrzeba
PGS Software S.A.
Your reliable partner in Poland - IT Outsourcing - BlackBerry, iPhone, Web and Standalone applications