Rect width exceeds maximum margin (cocos2d-js) - cocos2d-js

I get this error when I tried to load in a spritesheet
// create sprite sheet
cc.spriteFrameCache.addSpriteFrames(res.ant_walk_plist);
this.spriteSheet = cc.SpriteBatchNode.create(res.ant_walk_png);
this.addChild(this.spriteSheet);
I used TexturePacker to generate the spritesheet png and plist.
I tried to google the error and someone else mentioned updating cocos2d-js to the latest commit on git and I already did that..

Hours later I realized that I had files name as "ant#2x_1.png" and "ant#2x_2.png" (naming convention for retina) and somehow this screwed everything up and I don't know why. I just changed the names to "ant_1.png" and "ant_2.png" and everything is fine... JavaScript is always so very pleasant to work with.

Related

How to set path to picture in folder in device in android appcelerator app

So I have app where I want to let users to share screenshot of score to facebook etc... I'm using SocialShare widget. In documentation it says to set path to image like this: "image:fileToShare.nativePath", but I'm not really sure how to set it. Another problem is that I need to share picture that has always different name, it saves screenshots with names like tia7828157.png,tia107997596.png... in folder in device internal memory in pictures/enigmania/ I'm new to appcelerator, so I dont know if there is something like wildcard I could use for this? Thanks for any help.
This is my code so far which I know is wrong, I know the widget works because it shares text without problem:
function shareTextWidget(e){
// share text status
var socialWidget=Alloy.createWidget('com.alcoapps.socialshare');
socialWidget.share({status:"Enigmania kvíz",androidDialogTitle:"hoho",image:test.png/pictures/enigmania});
}
You should use Ti.Filesystem class methods/properties to get the path of any file located on internal or external storage.
Also aware of the permissions of reading storage on Android 6+. Use Storage Permissions before accessing any file on Android 6+.
Simple code snippet to create a directory on internal storage at this location: pictures/enigmania and then write an image file of captured view in this directory.
function shareTextWidget(e){
var directory = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'pictures/enigmania');
!directory.exists() && directory.createDirectory();
var fileToShare = Ti.Filesystem.getFile(directory.resolve(), 'screen.jpg');
fileToShare.write($.SCREENSHOT_VIEW.toImage()); // write the blob image to created file
var socialWidget=Alloy.createWidget('com.alcoapps.socialshare');
socialWidget.share({status:"Enigmania kvíz",androidDialogTitle:"hoho",image:fileToShare.nativePath});
}
This code should work without any issues.
Note that $.SCREENSHOT_VIEW is the View ID for which you will take screenshot, so it depends on you how you maintain your View positions in order to capture correct screenshot, but point is to use Ti.UI.View toImage() method to capture the screenshot of particular view.
Let me know if this works for you or not, else we can look into other methods by getting your exact requirements. Good Luck!!!!

Adding a new language to Tesseract ios SDK

I am able to compile the English version which is already in sample for tesseract but not able to add other language like swe.traineddata.
I'm doing like this
G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:#"eng+swe"];
When adding this its giving this error but working fine with English.
Cube ERROR (CubeRecoContext::Load): unable to read cube language model params from /private/var/mobile/Containers/Bundle/Application/D93B654A-1E46-4A34-9A83-95C6FC903085/*.app/tessdata/swe.cube.lm
Cube ERROR (CubeRecoContext::Create): unable to init CubeRecoContext object
init_cube_objects(true, &tessdata_manager):Error:Assert failed:in file tessedit.cpp, line 203
The fact it does not work has to do with the engine mode. If you use the CubeOnly or TesseractCubeCombined, you need 'cube' files. Engine mode TesseractOnly works fine.
you are missing some of files,I think so.Also check on Create Folder References.that helped me once.

iOS - UIImage imageNamed: returns null on device

[UIImage imageNamed:filename]
This method returns null only on the device.
I know it's known problem and it's usually due to the fact that simulator is case insensitive.
I have tried solutions proposed here: UIImage imageNamed returns nil
But nothing worked out for me.
The case is simple: I have 4 files named:Bar#2x~ipad.png, Bar#2x~iphone.png, Bar~ipad.png, Bar~iphone.png.
All of them are in project with target checkbox checked.
NSLog(#"%#",[UIImage imageNamed:#"Bar"]);
That line of code gives me null for device and I really have no idea what I'm doing wrong right now.
I did have such a problem recently too.
After playing with filenames and paths sometimes it helps when you clean and rebuild your project.
I found myself in the same situation recently.
The solution in my case was adding the extension to the file name.
[UIImage imageNamed:#"Bar.png"]
Completely clean your build and redo it:
delete the app from the device
option-clean the whole build directory in Xcode (⌘-Shift-K)
quit xcode
delete ~/Library/Developer/Xcode/DerivedData
restart xcode, build and run
This just happened to me, and to discover was very tough: I had one image which where nil just on device
logoWhite.png
my code:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"LogoWhite"] forBarMetrics:UIBarMetricsDefault];
After a while of debugging, I noticed that the name of the image is beginning with capital case letter. Obviously this doesn't matter on OSX with a ignore case file system. iOs file system isn't, so the image worked on the simulator but not on the device.
I bet that all the solutions about cleaning derived data and rebuild did randomly end with renaming the image, and this would do the trick as well. Just posting here for future reference :)
I encountered this issue and just fixed it. I listed the solution below as a reference.
I have several images, and use [UIImage imageNamed:filePath] to show them. All of images displayed well except 1 on simulator/device, but all of them can be seen on OS X. For that image, [UIImage imageNamed] always return null.
After few minutes' investigation, I found that the image cause problem is far big in file size: 4.1M. Others are all around 800kb. They have nearly same size in dimension.
Then I try to open it in image editor, then re-save it. After this, the size dropped to 800k. problem solved.
The reasons I guess,
[UIImage imageNamed:filePath] has a max file size limit? (low possibility, but need to check official document)
the image itself has some error. But OS X has better tolerance than iOS. so iOS cannot read and return null. This issue is like OS X can play more types of video files than iOS since it support more codecs.
so if you encounter this issue in the future, take a few seconds look at the file size. Hope help.
This is an odd problem, which I hadn't seen until this week.
Below are my findings, and a workaround to your problem.
In my iPhone app, I download an image and store it locally, and this had always worked fine.
But now when I run the same code, it was suddenly failing to create a UIImage out of it using the imageNamed function, and now it was returning nil.
Three notes though:
This exact code did work before, using the same source code and .png image files. I'm not sure if my copy of XCode 6.x or iOS 8.x quietly updated itself in the meantime.
The code continues to work okay (with the same image file) on the iPhone simulator. It just doesn't work on a real device.
Take a look at the code below. When UIImage:imageNamed failed, I ran some code to check if the file actually existed.. and it did. Then I loaded the binary data from the file using NSData:contentsAtPath (which also proves that the file exists and was in the right folder), then created a UIImage out of that, and it worked fine.
Huh ?!
UIImage* img = [UIImage imageNamed:backgroundImageFilename];
if (img != nil)
{
// The image loaded fine (this always worked before). Job done.
// We'll set our UIImageView "imgBackgroundView" to contain this image.
self.imgBackgroundView.image = img;
}
else
{
// We were unable to load the image file for some reason.
// Let's investigate why.
// First, I checked whether the image was actually on the device, and this returned TRUE...
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:backgroundImageFilename];
if (fileExists)
NSLog(#"Image file does exist.");
else
NSLog(#"Image file does not exist.");
// Next, I attempted to just load the bytes in the file, and amazingly, this also worked fine...
NSData *data = [[NSFileManager defaultManager] contentsAtPath:backgroundImageFilename];
if (data != nil)
{
// ..and then I COULD actually create a UIImage out of it.
img = [UIImage imageWithData:data];
if (img != nil)
{
// We have managed to load the .png file, and can now
// set our UIImageView "imgBackgroundView" to contain this image.
self.imgBackgroundView.image = img;
}
}
}
As I said, this code does provide a workaround for this problem, but it's very odd that it's suddenly started happening.
And, I should say, I did try the other suggestions in this thread, cleaning the project, removing the DerivedData, completely removing the app from the device, and so on, but they didn't make any difference.
I would be interested in knowing if anyone else hits this issue, and finds that my code sample works for them.
Update
I'm an idiot.
I'm not sure if the UIImage:imageNamed function has changed or something (and if so, why it continues to work okay on the iPhone 8.1 Simulator), but I found the following one line does work okay:
UIImage* img = [[UIImage alloc] initWithContentsOfFile:backgroundImageFilename];
So it seems as though you should use this function for loading images which aren't a part of your app's bundle.
I also have same issue then : XCode - Build Phases - Copy Bundle Resources -{see image is available or not}- add{image} - clean - delete app - Run .
I would like to add one more important point to all the above solutions
Make sure you add your image resource to right target
By mistake if Developer mess-up link with resource and target then conditions arise.
if you have multiple target then double check the resource are set to correct target.
Attached screenshot example in case of resource link between multiple targets.

OpenCV Line-Mod problems with Images

I'm trying to use line-mod (in special line-2d) in opencv 2.4 to compare images. At the moment I try to change the test-implementation linemod.cpp to use an input images instead of the camera, but without any success.
I tried to load an image via imread('...', CV_LOAD_IMAGE_COLOR); and pushed that in the sources vector but got a 'OpenCV Error: Assertion failed (response_map.rows % T == 0) in linearize' error.
If I load a CV_LOAD_IMAGE_GRAYSCALE image the run stops at detector->match with the error 'Thread 1: EXC_BAD_ACCESS (code=1, address=0x11310f000)'.
I don't understand what makes the difference between images coming from a VideoCapturer and from imread...
Is there anyone out there that may help me? I'm totally lost ... again ;-)
(For example sample code for matching two objects from images with linemod would be absolutely great!)
I use opencv 2.4 with xcode on a mac.
Maybe it is too late for an answer, but I am also interested in the algorithm
In the OpenCV Minutes 2012-06-26 ( http://code.opencv.org/projects/opencv/wiki/2012 ) you can read:
Will work with Stefan Hinterstoisser for final version of LINEMOD by September
So if you did not already solve it, you may want to wait.

LevelHelper and Corona SDK

Why do I get a black screen when I generate Lua code from the newest version (1.4.7) of LevelHelper My Old Level files work with my code and it generated only one lua file. The new one generates a set of 10-12 files, and leaves me with a black screen on the Corona simulator.
Am I doing anything drastically wrong?
Has the use of Level Helper changed with the new version?
All the tutorials and blogs I checked are showing the use of the old LevelHelper. any repositories / github links you would like to point me to?
For everybody else who has this problem, your config.lua file must look something like this
application =
{
content =
{
fps = 60,
width = 320,
height = 480,
scale = "letterbox",
imageSuffix =
{
["-hd"] = 2
}
},
LevelHelperSettings =
{
imagesSubfolder = "Images",
levelsSubfolder = "Levels",
directorGroup = nil
}
}
Have you seen this?
http://www.levelhelper.org/?page_id=1596
And also the latest tutorial for Corona SDK that talk LevelHelper 1.4
http://www.levelhelper.org/?p=1821
While the old LevelHelper was generating only one lua file - the new one generated multiple files because it added many complex features that could not be encapsulated in only one lua file.
Also, i want to stress that if you want fast response you should mail me or write to the LevelHelper forum.
I can help you out with your code and what you're doing wrong if you show me how you load the level.
Since you probably load it as the old way you should read the Getting Started chapter in the API Documentation.
You are probably missing the config.lua settings.

Resources