Got error on Large Image Size (1600*2560) png format? - cocos2d-android

I got an error on Large Image size is about 1600*2560. LogCat Detail is below :
E/AndroidRuntime(2451): FATAL EXCEPTION: main
E/AndroidRuntime(2451): java.lang.OutOfMemoryError
E/AndroidRuntime(2451): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime(2451): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache$2.load(CCTextureCache.java:210)
E/AndroidRuntime(2451): at org.cocos2d.opengl.CCTexture2D.setLoader(CCTexture2D.java:194)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache.createTextureFromFilePath(CCTextureCache.java:201)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCTextureCache.addImage(CCTextureCache.java:67)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCSprite.<init>(CCSprite.java:366)
E/AndroidRuntime(2451): at org.cocos2d.nodes.CCSprite.sprite(CCSprite.java:267)
What is the solution for this ?

When you use BitmapFactory to decode your file, you have to specify the Options, such as image width, height, color format, sample size. Then you will not run out of your memory.

Related

How do i convert a P2 pgm to a P5 pgm using Opencv?

i'm using a chan-vese segmentation code that only works with P5 pgm files, but i need to use it with P2 pgm files as well.
i am using OpenCV to try to convert it from P2 to P5, the problem i'm having is that i get an error when i try to save the image to binary format (used in P5). here the code:
Mat imag(imread("path_to_file.pgm", CV_LOAD_IMAGE_GRAYSCALE));
vector<int> param;
param.push_back(CV_IMWRITE_PXM_BINARY);
param.push_back(1);
try
{
imwrite("P5_file.pgm", imag, param);
}
catch (const std::exception &erro)
{
cout << &erro;
}
When debugging in Visual Studio, when the function imwrite is used i get an error in xutility internal header, i have no idea where this is from, but it shows me that its an access violation. _Pnext.
if i try to change the flag for reading the image, then i get:
Error: Bad argument (Portable bitmap(.pgm) expects gray image)
what is wrong here?

UE4 Data Table Struct Errors

I'm following a Packt tutorial regarding CSV table entry. The tutorial requires that I a) create a new Actor class, b) name it TestCustomData, and c) replace the contents of the newly-generated TestCustomData.h with the following code:
#pragma once
#include "TestCustomData.generated.h"
USTRUCT(BlueprintType)
struct FTestCustomData : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
int32 SomeNumber;
UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
FString SomeString;
};
However, the TestCustomData file fails to compile, outputting the following log:
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Info Compiling game modules for hot reload
Info Parsing headers for UE4_ProjectRPGEditor
Info Running UnrealHeaderTool "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\UE4_ProjectRPG.uproject" "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Intermediate\Build\Win64\UE4_ProjectRPGEditor\Development\UE4_ProjectRPGEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Info Reflection code generated for UE4_ProjectRPGEditor in 3.4146568 seconds
Info Performing 4 actions (4 in parallel)
Info TestCustomData.cpp
Info UE4_ProjectRPG.generated.cpp
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Info ERROR: UBT ERROR: Failed to produce item: F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Binaries\Win64\UE4Editor-UE4_ProjectRPG-3031.dll
Info Total build time: 6.88 seconds (Local executor: 0.00 seconds)
I'm fairly new to StackOverflow and C++ in UE4, and any help would be appreciated. Any feedback to improve my question is also welcome! Thanks in advance for your help.
I was stuck at the same spot and this fixed it:
I named the Asset "MyActor2" and the Strucure "ThisNewStructure" so there are some little differences...
I think it was basicly including the Datatable.h and the "public:" that did the trick.
Header File:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Engine/DataTable.h"
#include "MyActor2.generated.h"
USTRUCT(BlueprintType)
struct FThisNewStructure : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
int32 SomeNumber;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
FString SomeString;
};
cpp:
#include "MyActor2.h"
Then it compiles successful.
I had to do some closing/reopening of VS & UE for the Editor to know about the new structure.
It may be a little late, but I just ran into this myself. Sometimes you'll have an include that automatically grabs the FTableRowBase, but sometimes a class doesn't have a header that calls back to it. In that case:
#pragma once
#include "Engine/DataTable.h"//this is where FTableRowBase is declared.
#include "TestCustomData.generated.h"
struct FFoo : FTableRowBase
{
GENERATED_USTRUCT_BODY()
public:
the rest of your class...
I hope this helps! :D
Thanks for the help, I was working through the same problem in the same tutorial. Apparently you didn't need to rename TestCustomData to MyActor2, you just needed to add the line "public:" after the "GENERATED_USTRUCT_BODY()".

How to view Exception Details Visual Studio "Unhanded exception was encountered during a user callback"

My Visual Studio devenv.exe crashes intermittently, and if I debug it I see the following:
Is there any way to view the exception that was thrown so I might have a clue what caused the crash?
What exactly does "user callback" mean in this context that makes it different from just a generic "Unhandled exception" dialog that Visual Studio might display like the following:
Here is the call stack for my crashed devenv.exe process if that helps explain how to view any exception details.
> user32.dll!_NtUserMessageCall#28() Unknown
user32.dll!_NtUserMessageCall#28() Unknown
user32.dll!_NtUserQueryWindow#8() Unknown
uxtheme.dll!_ThemeDefWindowProc(struct HWND__ *,unsigned int,unsigned int,long,int) Unknown
uxtheme.dll!_ThemeDefWindowProcW#16() Unknown
user32.dll!_DefWindowProcW#16() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_CallWindowProcAorW#24() Unknown
user32.dll!_CallWindowProcW#20() Unknown
WindowsBase.ni.dll!66288900() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for WindowsBase.ni.dll]
WindowsBase.ni.dll!66288900() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_CallWindowProcAorW#24() Unknown
user32.dll!_CallWindowProcW#20() Unknown
WindowsBase.ni.dll!662a385a() Unknown
WindowsBase.ni.dll!662a385a() Unknown
004ca2da() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_DispatchClientMessage#24() Unknown
user32.dll!___fnDWORD#4() Unknown
ntdll.dll!_KiUserCallbackDispatcher#12() Unknown
user32.dll!_NtUserMessageCall#28() Unknown
user32.dll!_RealDefWindowProcWorker#24() Unknown
user32.dll!_RealDefWindowProcW#16() Unknown
uxtheme.dll!_ThemeDefWindowProc(struct HWND__ *,unsigned int,unsigned int,long,int) Unknown
uxtheme.dll!_ThemeDefWindowProcW#16() Unknown
user32.dll!_DefWindowProcW#16() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_CallWindowProcAorW#24() Unknown
user32.dll!_CallWindowProcW#20() Unknown
WindowsBase.ni.dll!66288900() Unknown
WindowsBase.ni.dll!66288900() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_CallWindowProcAorW#24() Unknown
user32.dll!_CallWindowProcW#20() Unknown
WindowsBase.ni.dll!662a385a() Unknown
WindowsBase.ni.dll!662a385a() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_SendMessageWorker#24() Unknown
user32.dll!_SendMessageW#16() Unknown
02bc900a() Unknown
02bc8c27() Unknown
WindowsBase.ni.dll!66288622() Unknown
WindowsBase.ni.dll!6628855a() Unknown
WindowsBase.ni.dll!6628ac3c() Unknown
WindowsBase.ni.dll!6628ab88() Unknown
mscorlib.ni.dll!727ada07() Unknown
mscorlib.ni.dll!727ad956() Unknown
mscorlib.ni.dll!727ad921() Unknown
WindowsBase.ni.dll!6628aaab() Unknown
WindowsBase.ni.dll!6628742b() Unknown
WindowsBase.ni.dll!662875ca() Unknown
WindowsBase.ni.dll!6628880b() Unknown
WindowsBase.ni.dll!6628875b() Unknown
WindowsBase.ni.dll!66288622() Unknown
WindowsBase.ni.dll!6628855a() Unknown
WindowsBase.ni.dll!66286cfe() Unknown
WindowsBase.ni.dll!662880e1() Unknown
004ca2da() Unknown
user32.dll!_InternalCallWinProc#20() Unknown
user32.dll!_UserCallWinProcCheckWow#32() Unknown
user32.dll!_DispatchMessageWorker#8() Unknown
user32.dll!_DispatchMessageW#4() Unknown
msenv.dll!MainMessageLoop::ProcessMessage(struct IMsoStdComponentMgr *,struct IVsWindowManager *,struct tagMSG &) Unknown
msenv.dll!CMsoCMHandler::EnvironmentMsgLoop(void) Unknown
msenv.dll!CMsoCMHandler::FPushMessageLoop(unsigned long) Unknown
msenv.dll!SCM::FPushMessageLoop(class SCMI *,unsigned long,void *) Unknown
msenv.dll!SCM_MsoCompMgr::FPushMessageLoop(unsigned long,unsigned long,void *) Unknown
msenv.dll!CMsoComponent::PushMsgLoop(unsigned long) Unknown
msenv.dll!VStudioMainLogged(void) Unknown
msenv.dll!_VStudioMain() Unknown
devenv.exe!util_CallVsMain(struct MAINPARAM *,int *) Unknown
devenv.exe!CDevEnvAppId::Run(unsigned short *,int) Unknown
devenv.exe!_WinMain#16() Unknown
devenv.exe!__tmainCRTStartup() Unknown
kernel32.dll!#BaseThreadInitThunk#12() Unknown
ntdll.dll!___RtlUserThreadStart#8() Unknown
ntdll.dll!__RtlUserThreadStart#8() Unknown

Open an HDF5 file error

I created an HDF5 file open function like the following:
int OpenHDF5(string sFileName)
{
// Check for valid HDF5 file
if (!H5File::isHdf5(sFileName.c_str()))
{
// Invalid HDF5 file
return -1
}
// Try block to detect exceptions raised by any of the calls inside it
try
{
// Turn off the auto-printing when failure occurs so that we can handle the errors appropriately
Exception::dontPrint();
// Now Open the file
H5File file( sFileName.c_str(), H5F_ACC_RDONLY );
}
// Catch failure caused by the H5File operations
catch( FileIException error )
{
error.printError();
return -1
}
return 0
}
No compiling error occurred, but failed to link with the following exceptions:
Linking...
Creating library F:\Tips\Debug\Tips.lib and object F:\Tips\Debug\Tips.exp
TwinSatObservation.obj : error LNK2001: unresolved external symbol "public: static class H5::FileCreatPropList const H5::FileCreatPropList::DEFAULT" (?DEFAULT#FileCreatPropList#H5##2V12#B)
TwinSatObservation.obj : error LNK2001: unresolved external symbol "public: static class H5::FileAccPropList const H5::FileAccPropList::DEFAULT" (?DEFAULT#FileAccPropList#H5##2V12#B)
F:\Tips\Debug\Tips.exe : fatal error LNK1120: 2 unresolved externals
I added the following libraries to "Addtional Dependencies" input box of the VS 2008 Linker
hdf5dll.lib
hdf5_hldll.lib
hdf5_cppdll.lib
hdf5_hl_cppdll.lib
Would you please tell me which library I forgot to add? Thank you very much!
As for hdf5-1.8.17 with either VS2010 or VS2015, defining H5_BUILT_AS_DYNAMIC_LIB as a preprocessor setting (Project > Properties > C/C++ > Preprocessor > Preprocessor Definitions) cures exactly the same symptom for me. Thanks to the original post.
Add HDF5CPP_USEDLL;_HDF5USEDLL_; in Preprocessor Definitions input box.

VS 2008 C++ error C2059 and C2238

I'm trying to port a program/game that was developed in linux/g++ so that it runs on windows 7 VS 2008 C++. The program uses libraries such as OpenGL, SDL, and Boost.
I've solved a lot of errors but I'm kind of stuck on this one.
I get error code C2059 and C2238. The actual error messages are:
------ Build started: Project: Asteroid Blaster, Configuration: Release Win32 ------
Compiling...
WeaponDisplay.cpp
Weapon.cpp
ViewFrustum.cpp
Vector3D.cpp
UDP_Server.cpp
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2238: unexpected token(s) preceding ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2238: unexpected token(s) preceding ';'
UDP_Client.cpp
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2238: unexpected token(s) preceding ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2238: unexpected token(s) preceding ';'
TractorBeamShot.cpp
The ViewFrustum.h file is as follows:
/**
* viewFrustum: It's got useful functions to cull items that aren't in your view frustum
*
* 2-7-11
* CPE ---
*/
#ifndef __VIEW_FRUSTUM_H__
#define __VIEW_FRUSTUM_H__
#include "Items/Object3D.h"
#include "Utility/Plane.h"
#include "Utility/Matrix4.h"
#include <vector>
#include <set>
class ViewFrustum {
public:
ViewFrustum();
virtual ~ViewFrustum();
/* Takes in a list of all the Object 3D's around, and culls them down to only the ones
* that are inside the view frustum.
*/
virtual std::list<Drawable*>* cullToViewFrustum(std::vector<Drawable*>* all, bool skipParticles);
virtual std::list<Object3D*>* cullToViewFrustum(std::vector<Object3D*>* all);
/* Prints out details about all of the planes of the view frustum.
*/
virtual void print();
private:
Matrix4 projMatrix;
Matrix4 modelViewMatrix;
Plane* top;
Plane* bottom;
Plane* left;
Plane* right;
Plane* near;
Plane* far;
/**
* A modified version of chedDrawableOutside, used by the AI. This stops the
* AI from targeting Drawable objects which are slightly outside the field
* of view, which still need to be drawn.
*/
bool checkTargetableOutside(Drawable* obj);
/* Returns true if the Drawable object is completely outside of the
* view frustum planes.
* Returns false if it's even part-way inside.
*/
virtual bool checkDrawableOutside(Drawable* obj);
};
#endif
The offending lines (40-41) are:
Plane* near;
Plane* far;
It's kind of confusing because the ViewFrustum obj got compiled already but when it gets to UDP_Server.cpp and UDP_Client.cpp, it throws an error. I'm not sure if it matters but the UDP classes use Boost's aiso and serialization modules. I know Boost sometimes gives out weird warnings but I'm not sure if Boost has to do anything with this error.
If anyone has any idea why this is or if you need more code posted, please let me know.
Chances are you're including a windows header before that one, and near and far are defined somehwere in there. Those are (legacy) things from the 16bit era.
See this related question Is there a clean way to prevent windows.h from creating a near & far macro? for workarounds.