I'm confused because I cannot establish why my ImageList_Add call is failing. I know it must be something that I am doing wrong with the Image or maybe I'm calling it wrong but I have no idea how I can go about fixing it :S Any help you can offer would be appreciated! :)
The code i'm using is below. I'm getting output on the console saying it couldn't add to the image list. From the docs,ImageList_Add will return an indice of where in the imagelist it managed to add the image so -1 is returned if it cant.
Which is all well and good but I cannot find anywhere why/what causes the add to fail!
The code may have memory leaks, though at the moment,ive spent almost a day trying to figure out various issues with this so I just want to get it to work!
HIMAGELIST imageList = ImageList_Create(20,20,ILC_COLOR16,1,2 );
if (imageList == NULL)
{
printf("Error creating imagelist - dlg_create_dropdown_menu. Returning NULL\n");
return NULL;
}
HBITMAP currentImage = (HBITMAP) LoadImage(NULL,"active_mdoe_icn.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if (currentImage == NULL)
{
if (GetLastError()== 2)
{
printf("File not found - dlg_create_dropdown_menu. Returning NULL.\n");
return NULL;
}
printf("Error loading image from file - dlg_create_dropdown_menu. Returning NULL.\n");
return NULL;
}
int imageIndex;
if ( (imageIndex = ImageList_Add(imageList,currentImage,NULL)) == -1 )
{
printf("Error adding to the image list - dlg_create_dropdown_menu. Returning NULL.\n");
return NULL;
}
Thanks all, any help would be greatly received! :)
Could this be a problem with the actual image being corrupt? I've read about that in a few places.. Might just be my luck if i'm not doing anything daft :)
After much arguing with myself and windows I didnt figure out why the add was not working.
Instead of trying using the imagelist I just load in each image one at a time at work with it that way. Not sure why I thought using the image list was better :s
I was trying to load images into a dropdown menu I was creating but I found a better way of doing it. Which was using the MENUITEMINFO struct and specifying MIIM_BITMAP | MIIM_STRING as the two flags to fMask :) which mean I could have an image and an text in each menu item :)
Also image names with 0 underscores somehow makes it easier for windows to find lol
Anyways, hope this helped someone :)
Related
I'm interested in seeing if I can modify some XMP within an image file. I'm using the following code:
var items = MetadataExtractor.ImageMetadataReader.ReadMetadata(_filename);
foreach (var item in items)
{
if(item.Name == "XMP")
{
var y = new XmpCore.Impl.XmpMeta();
var xmp = item as MetadataExtractor.Formats.Xmp.XmpDirectory;
foreach(var xd in xmp.XmpMeta.Properties)
{
if(xd.Path == "drone-dji:AbsoluteAltitude")
{
var alt = Convert.ToDecimal(xd.Value.Substring(1,xd.Value.Length-1));
alt -= 100;
xmp.XmpMeta.SetProperty(xd.Namespace, xd.Path, alt.ToString());
}
}
xmp.SetXmpMeta(xmp.XmpMeta);
}
}
I know I'm missing something breathtakingly obvious but I don't know this library well enough to figure it out.
No exceptions come up but when I open up the file the XMP field is still the same. When I iterate thru the xmp properties after I set the property it does reflect correctly but when I end the program the file stays the same. I'm sure there's something to do with writing back to the image path but I have no idea where in this library I do that. Any help would be greatly appreciated.
MetadataExtractor doesn't support modifying files. You can update the data structure, as you show, but there's no way to write those changes back to your original file.
I have a Tizen Edje file which defines my layout. One part is an image with part name 'warning'. The item is set to visible in the edge file, and it shows as expected.
I want to hide this part using C code:
Evas_Object* image_NotSetYet = (Evas_Object *) edje_object_part_object_get(elm_layout_edje_get(wid->edjeLayout), "warning");
if (image_NotSetYet == NULL) {
dlog_print(DLOG_ERROR, LOG_TAG, "View: Unable to get warning image part");
return;
}
evas_object_hide(image_NotSetYet);
I have tried many different ways to get the Evas Object associated with this part name and hide it. After many hours I stumbled onto some code that I modeled after, and it seems to work. I can hide (and show) my image part now.
However, I later add an unrealted image to a swallow in this layout and show it. All of a suddent the 'warning' part image shows again. Why? Am I hiding the 'warning' part the wrong way? Is there something wrong with the above?
Alternatively, is there something wrong with the way I am adding an image to the swallow below? The image (from file) will show up, but suddenly my warning part above shows too:
Evas_Object *img = elm_image_add(wid->edjeLayout);
if (img == NULL) {
dlog_print(DLOG_ERROR, LOG_TAG, "View: Failed to add a image.");
return;
}
// Create an image and set contents to imagefile
char *imageFileName = barcode_filename();
bool isSet = elm_image_file_set(img, imageFileName, NULL);
dlog_print((isSet?DLOG_INFO:DLOG_ERROR), LOG_TAG, "View: %s file [%s] to image",(isSet==EINA_TRUE?"Set":"Failed to set"),imageFileName);
free(imageFileName);
evas_object_show(img);
// Assign the image to the swallow2 part
elm_object_part_content_set(wid->edjeLayout,"swallow2",img);
I tried adding the image to the 'window' instead of the 'layout' but that didn't seem to matter. (I've seen many contradictory examples so I don't know which is right)
I tried setting the image to the 'swallow2' part name many different ways (again, many contradictory ways show). Is this the problem?
Otherwise, can someone explain what is going wrong?
The image_NotSetYet is not an image object.
Evas_Object* image_NotSetYet = (Evas_Object *) edje_object_part_object_get(elm_layout_edje_get(wid->edjeLayout), "warning");
That refers to the "warning" swallow part object.
You should never modify the state of the returned object, because it's meant to be managed by Edje, solely.
If you want to get the image pointer from your layout as you expected, you could use following instead.
Evas_Object* image_NotSetYet = elm_object_part_content_get((wid->edjeLayout), "warning")
But as above link describes, the image object should be manged by Edje.
You might got the 2nd problem because it is managed by Edje. So please use edje_object_signal_emit to handle swallowed images.
Simply,
I have randomly placed and moving movie clips that will call victims And I Have another set of random Moving movie clips that have an attack animation I will call them assailants.
Victims wander randomly among Assailants an at random times the Assailants will shoot out a lightning bolt movie clip to attack the victims. It is at this point I am attempting to check for a collision between the victims and the assailants lightning Bolts.
Both types are in separate array's and I have before checked an array vs an array without a problem I have also checked static object vs an array objects internal MC without an issue. However I am Stuck when checking array vs array objects internal MC.
Code:
for(var j:int=0;j<NormalBubbleArray.length;j++){
for(var k:int=0;k<LightningStormArray.length;k++){
if(NormalBubbleArray[j].hitTestObject(LightningStormArray[k]).upbolt){
trace("hit")
NormalBubbleArray.removeAt([j]);
LightningStormArray.removeAt([k]);
}
}
}
I have also Tried
if(NormalBubbleArray[j].hitTestObject(LightningStormArray[k]).upbolt)
and 10 other ways to try and write it. Still no luck not sure if its my loop or collision detection at this point. It gives no errors when running so I assume my Syntax is Ok.
Thanks In Advance.
Update: I was tinkering with it and realized I had it wrapped in a try catch so I was not seeing the error. now my issue is this.
for(var j = 0; j<NormalBubbleArray.length;j++){
for(var k = 0; k<LightningStormArray.length;k++){
if((LightningStormArray[k]).upbolt hitTestPoint(NormalBubbleArray [j]), true){
trace("hit")
(NormalBubbleArray [j]).removeEventListener(MouseEvent.MOUSE_MOVE, ChildMouse);
NormalBubbleArray.removeAt([j]);
LightningStormArray.removeAt([k]);
}
}
}
Still Compiles but when it comes time to detect I get The following error in the output.
TypeError: Error #1006: value is not a function.
at BubblesReloaded_fla::MainTimeline/CollisionControl()
Help is appreciated.. I am still tinkering with it.
Got it !
Tricky Devil.
The debuger kept pointing to the hittest line and it had nothing to do with the actual line it hilighted but what was inside the if statment that caused the issue.
var Lstormpoints:int = 0;
for(var j = 0; j<NormalBubbleArray.length;j++){
for(var k = 0; k<LightningStormArray.length;k++){
if(LightningStormArray[k].upbolt.hitTestPoint(NormalBubbleArray [j]), true){
trace("bubble is hit")
NormalBubbleArray [j].removeEventListener(MouseEvent.MOUSE_MOVE, ChildMouse);
NormalBubbleArray [j].gotoAndPlay(10)/// was (NormalBubbleArray [j]).gotoAndPlay(10) // was causing an error
NormalBubbleArray.removeAt([j]);
LightningStormArray.removeAt([k]);
}
}
}
What threw me off was that the debugger kept pointing to the if statement as the error. What I did not catch is it was trying to tell me that it was an error inside the if statement. I figured it out after some heavy tracing I Noticed that it was detecting collision but the Bubble was not acting as if it got hit giving me the illusion that it was not detecting hit. the gotoAndPlay line animates the death and sadly that was the line with the issue.. just happy I got it going.
Thank you for your interest in my question, I cannot seem to find a remedy for this problem. I am trying to display an array of 17,272 characters horizontally (in the same line) in console application and I tried some of the solutions that were mentioned in stackoverflow like using console.write instead of control.writleine and adding string.join but the result is not what I want but close to what I want, I say close because the output of the 17,272 characters break into the next line at the end of the window. I would appreciate to know whether this is even possible. My code is below. thank you.
for (int i = 0; i < genome1.Length; i++)
{
Console.Write(string.Join(" Genome 1= {0}", genome1[i]));
}
I'm using the MiniXML library to parse a XML file in C, however when i try to read the node's value it returns NULL.
Here's the code:
FILE *fp;
mxml_node_t *tree;
fp = fopen("test.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK);
fclose(fp);
mxml_node_t *node;
for(node = mxmlFindElement(tree, tree,"node",NULL, NULL,MXML_DESCEND);
node != NULL;
node = mxmlFindElement(node, tree,"node",NULL, NULL, MXML_DESCEND)) {
printf("Text: %s\n", node->value.text.string);
}
The problem is that node->value.text.string is NULL. I've been reading the documentation and I don't know what im doing wrong. Has anybody run into this problem before?
Try changing your for-loop to specify:
node->child->value.text.string
instead of:
node->value.text.string
Does that work? It's just a guess, but I'm thinking it might be necessary to get the data for the "node" elements.
If that does not work, look at C++: Trouble loading long string from XML file using Mini-XML. This person says they needed to use MXML_DESCEND_FIRST instead of MXML_DESCEND to fix their problem. I'm not sure if it would help in your case.
If neither of these work, you might post your input XML as well so that we can try to recreate your problem.
I got the same error. Thanks for the link you posted. I can fixed the error by changing
node->child->value.text.string in node->child->value.opaque.
nothing to change when the file is opened because the type_cb function select the right case.
Minixml bug 502 - minixml mxmlLoad*() functions fail to load text with MXML_TEXT_CALLBACK.
To work around, define and use your own text callback