Beispiel #1
0
int main(int argc, char* argv[]) {
	fprintf(stdout, "main called\n");
	char szFileName[] = "/input.jpg";
	char szFileNameOut[] = "/output.bin";
	loadJpg(szFileName, szFileNameOut);
	return 1;
}
bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageType)
{
	bool bRet = false;

	switch (imageType)
	{
	case kCCImageFormatPNG:
		// use libpng load image
		bRet =  loadPng(strPath.c_str());
		break;
	case kCCImageFormatJPG:
		bRet = loadJpg(strPath.c_str());
		break;
	default:
		// unsupported image type
		bRet = false;
		break;
	}

	if (!bRet && s_bPopupNotify)
	{
		// notify the loading error
		std::string strErr = "Load ";
		strErr += strPath;
		strErr += " failed!";
		std::wstring wsErr(strErr.length(), L'');
		std::copy(strErr.begin(), strErr.end(), wsErr.begin());
		MessageBox(NULL, wsErr.c_str(), L"cocos2d-x error", MB_OK);  
	}

	return bRet;
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    Image_t myImage;
    int result;

    char *filename = "frames/frame01.jpg";

    result = loadJpg(filename, &myImage);

    printf("Loading image %s, result=%d\n",filename,result);
    printf("Image height = %d, width = %d\n",myImage.height, myImage.width);

    pixel_t p = myImage.data[0];
    printf("Pixel[0] has values (%u, %u, %u)\n", p.L, p.A, p.B);
    // free the memory
    free( myImage.data );

    return 0;
}
int readImageFrame(frame_t *frame, char *fileName){
    // Load image into the structure
    Image_t *img = (Image_t *)(malloc(sizeof(struct Image_s))); 
    if (img == NULL) {
        printf("readImageFrame: Unable to malloc img pointer\n");
        return -1;
    }
    if (loadJpg(fileName, img) == 0){
        printf("readImageFrame: Unable to read image at [%s]\n", fileName);
        return -1;
    }
    frame->image = img;
   
    // Initialize the other variables in the structure
    frame->boxes = NULL;
    

    LOG_ERR("readImageFrame: Image height = %d, width = %d\n", img->height, img->width);
    return 0;
}
Beispiel #5
0
bool Bitmap::loadData(const uint8_t * data, size_t dataLen, const StrideFn &strideFn) {
	bool ret = false;
	if (isPng(data, dataLen)) {
#ifndef NOPNG
		if (loadPng(data, dataLen, _data, _color, _alpha, _width, _height, _stride, strideFn)) {
			ret = true;
		}
#endif
	} else if (isJpg(data, dataLen)) {
#ifndef NOJPEG
		if (loadJpg(data, dataLen, _data, _color, _alpha, _width, _height, _stride, strideFn)) {
			ret = true;
		}
#endif
	} /* else if (isWebp(data, dataLen)) {
		if (loadWebp(data, dataLen, _data, _color, _alpha, _width, _height)) {
			ret = true;
		}
	} */
	return ret;
}