Hello,
I am trying to modify some color information from java to C.
I have the information given by java in a format ARGB and I would like to
convert it as:
RRRR...GGGG...BBB....
without the A composant. Separating the A,R,G,B part is not hard. My main
problem is the size of my images.
I have something like
jsize len = env -> GetArrayLength(arr);
where len = 3145728 (for a given image The width 2048, the height 1536)
I have tried to put it inside a unsigned char variable vector, but it doesn't
work well. I seems like that's a lot of memory (Eclipse just stops executing the
jni program).
Do you have an idea in order to bypass this "memory" problem ?
thanks a lot,
Marcelo
The error is segmentation falut, and the code:
The error I get is
segmentation fault.
My code is:
void argb2rgb(JNIEnv *env, jobject obj, jintArray arr)
{
jsize len = env -> GetArrayLength(arr);
int *body = env -> GetIntArrayElements(arr, 0);
int compSize = len / 4 ;
printf("\n%d len:%d\n",compSize,len);
uchar rgbArr [3 * compSize];
uchar* pr = (uchar*) rgbArr;
uchar* pg = pr + compSize;
uchar* pb = pg + compSize;
//pg = pr + compSize;
//pb = pg + compSize;
int i = 0;
for( i = 0 ; i< 1; i++){
uchar red = ((body[i] >> 16) & 0xff);
//pr = &red;
uchar green = ((body[i] >> 8) & 0xff);
//pg = &green;
uchar blue = (body[i] & 0xff);
//pg = &blue;
int result = (red << 16) | (green << 8) | blue;
//printf("red %d pointer: %d result: %x",red, *pr, result);
}
env -> ReleaseIntArrayElements(arr, body, 0);
} 1 2537
Marcelo wrote: I am trying to modify some color information from java to C.
Neither is topical here. Or did you not know that C is a different
language than C++?
I have the information given by java in a format ARGB and I would like to convert it as:
RRRR...GGGG...BBB.... without the A composant. Separating the A,R,G,B part is not hard. My main problem is the size of my images.
What do you mean by that?
I have something like jsize len = env -> GetArrayLength(arr);
What's "jsize"? What's "env"? What's "arr"?
where len = 3145728 (for a given image The width 2048, the height 1536)
So, your 'GetArrayLength' function retuns you the result of multiplying
the width by the height. Is there a problem? It seems doing it right...
I have tried to put it inside a unsigned char variable vector, but it doesn't work well.
Read FAQ 5.8.
I seems like that's a lot of memory (Eclipse just stops executing the jni program).
You are losing me here... Are we being punk'd here? This is a C++
newsgroup, right? What's a lot of memory? 3 mebibytes?
Do you have an idea in order to bypass this "memory" problem ?
I don't see a memory problem. Perhaps you're being less than clear...
thanks a lot,
Marcelo
The error is segmentation falut, and the code: The error I get is segmentation fault.
Have you tried debugging it? You know, running it under a debugger...
My code is:
void argb2rgb(JNIEnv *env, jobject obj, jintArray arr) { jsize len = env -> GetArrayLength(arr); int *body = env -> GetIntArrayElements(arr, 0);
int compSize = len / 4 ; printf("\n%d len:%d\n",compSize,len);
uchar rgbArr [3 * compSize];
This is not C++. In C++ the expression inside brackets in an array
declaration MUST be compile-time cosntant. Maybe you meant
uchar *rgbArr = new uchar[3 * compSize];
?
uchar* pr = (uchar*) rgbArr;
There is no need to cast here.
uchar* pg = pr + compSize; uchar* pb = pg + compSize;
//pg = pr + compSize; //pb = pg + compSize;
int i = 0; for( i = 0 ; i< 1; i++){ uchar red = ((body[i] >> 16) & 0xff); //pr = &red;
uchar green = ((body[i] >> 8) & 0xff); //pg = &green;
uchar blue = (body[i] & 0xff); //pg = &blue;
int result = (red << 16) | (green << 8) | blue; //printf("red %d pointer: %d result: %x",red, *pr, result); }
env -> ReleaseIntArrayElements(arr, body, 0); }
And where is the segmentation fault?
V This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ws_dev2001 |
last post by:
Hello all,
I am trying to obtain the size of a java object in C by using JNI. As
we do not have a proper implementation of this in java, I decided to see if C could
provide me some accurate data....
|
by: Steve Amey |
last post by:
Hi all
I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by
using the Color.ToArgb method), is there any way that I can create a
System.Drawing.Image or a...
|
by: Sambucus |
last post by:
Hi group!
I am using C++ and java with JNI to get some text in a RICHEDIT to my
java program. I do so by accessing a C++ method every second. It all
works fine except that it leaks memory every...
|
by: ws_dev2001 |
last post by:
Hello all,
I am trying to obtain the size of a java object in C by using JNI. As
we do not have a proper implementation of this in java, I decided to see if C could
provide me some accurate data....
|
by: Sai Kit Tong |
last post by:
I posted for help on legacy code interface 2 days ago. Probably I didn't
make it clear in my original mail. I got a couple of answers but none of
them address my issues directly (See attached...
|
by: Samuel L Matzen |
last post by:
Hi NG,
I have an Argb color stored in a database as a 32 bit integer.
If this color is a KnownColor, is there any way I can get the known color
name so I can display the known color name on...
|
by: David Stevenson |
last post by:
Programs from: Sheng Liang, The Java Native Interface, Programmer's
Guide and Specification, The Java Series, (c) 1999, pp. 38-39.
I thought I copied the program pretty exactly, but I don't know...
|
by: heathimself |
last post by:
Hi,
I don't know what type of files they are, but the script allows me to
save to a bitmap just fine. But I do know they need to be in RGBA 4444
format, so I've followed what most of the tutorials...
|
by: myusernotyours |
last post by:
Hi All,
Am working on a Java application in which I have to use the JNI to Interface with some native code for both windows and unix. Am using netbeans IDE with the C/C++ pack installed. Am also...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |