⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jzimagedecode.cpp

📁 君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图片解码,浏览,电子书,录音,想学ucos,识货的人就下吧 russblock fmradio explore set
💻 CPP
字号:
/********************** BEGIN LICENSE BLOCK ************************************
 *
 * JZ4740  mobile_tv  Project  V1.0.0
 * INGENIC CONFIDENTIAL--NOT FOR DISTRIBUTION IN SOURCE CODE FORM
 * Copyright (c) Ingenic Semiconductor Co. Ltd 2005. All rights reserved.
 * 
 * This file, and the files included with this file, is distributed and made 
 * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
 * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
 * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
 * 
 * http://www.ingenic.cn 
 *
 ********************** END LICENSE BLOCK **************************************
 *
 *  Author: <dsqiu@ingenic.cn> <hlyu@ingenic.cn>
 *
 *  Create:   2008-03-04, by dsqiu
 *  Maintain: 2008-06-23, by hlyu
 *            
 *******************************************************************************
 */

#include "JzImage.h"
#include "xiofile.h"
#include "JzImagePng.h"
#include "JzImageBmp.h"
#include "JzImageJpg.h"
#include "JzImageGIF.h"
#include "JzImageInfo.h"

static char *findext(char *filename)
{
	int d = strlen(filename);
	int i;
	d--;
	if(d <= 0)
		return 0;
	for(i = d;i > 0;i--)
		if(filename[i] == '.')
			break;
	if(i > 0)
		return &filename[i + 1];
	return 0;		
}

extern "C"{
	//result: 0 -- error
	//result: 1 -- finish
/*
static void ivTest( void )
{
    void *p = CImageMemMgr::malloc( 480*272*4*8);
    printf(" cpp ------------------------------------------------------------------ malloc p: %x\n", p );
    CImageMemMgr::free( p );

}
*/	 
       void ShowGIF( CJzImage * );


       static IVSETIMAGEINFO ivSetImageInfo = NULL;

       void ivSetImageBuf( IVSETIMAGEINFO func)
       {
           ivSetImageInfo = func;
       }

	

	BOOL DecodeImage(char *filename, void *p)
	{
		PSCRINFO pscr = (PSCRINFO)p;
		char *ext;
		char s[6];
		int imagetype = 0;
                BOOL decodeOk = FALSE;
		unsigned char isImage = 0, isGIF = 0;
		CJzImage *image;

		//CxIOFile file(NULL);
		CxIOFile *file;
                printf("====== pscr->buffer: %x, pscr->w: %d, pscr->h: %d\n", pscr->buffer, pscr->w, pscr->h);
                printf("    ^^^^^^^^^ filename decode: %s \n", filename );
		ext = findext(filename);
		if(strcasecmp(ext,"JPG") == 0)
		{
			image = new CJzImageJPG(pscr);
			imagetype = 0;
			isImage = 1;
		}
		else if(strcasecmp(ext,"BMP") == 0)
		{
			image = new CJzImageBmp(pscr);
			imagetype = 1;
			isImage = 1;
			
		}
		else if(strcasecmp(ext,"PNG") == 0)
		{
			image = new CJzImagePng(pscr);
			imagetype = 2;
			isImage = 1;
			printf("read PNG File\n");
		}	
                else if(strcasecmp(ext,"GIF") == 0)
                {
                        image = new CJzImageGIF(pscr);
			imagetype = 3;
                        isImage = 1;
                        isGIF = 1;

                        //printf(" ==image->pScr->buffer== %x === giffilename : %s\n ",image->pScr->buffer,filename);
                }

		if(isImage)
		{
			file = new CxIOFile(NULL);
			if(file->Open(filename,"rb"))
			{	
				decodeOk = image->Decode((CxFile *)file);
				file->Close();
				switch(imagetype)
				{
					case 0:
					{
						CJzImageJPG *ima = (CJzImageJPG *)image;
						delete ima;
					}
					break;
					case 1:
					{
						CJzImageBmp *ima = (CJzImageBmp *)image;
						delete ima;
					}
					break;
					case 2:
					{
						CJzImagePng *ima = (CJzImagePng *)image;
						delete ima;
					}
					break;
					case 3:
					{
						CJzImageGIF *ima = (CJzImageGIF *)image;
						delete ima;
					}
                               } 
	
		         }
                         else
                         {
                             delete image;
                         }
		       delete file;
		}
		return decodeOk;
	}

IVSETIMAGEINFO ivGetImageInfoCallback( void )
{
    return ivSetImageInfo;
}

}//end extern "C"










⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -