/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include <stdio.h>
#include <malloc.h>
#include "libpng.h"
#include "..\..\libpng\png.h"
static void read_data_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
struct png_t* png = (struct png_t*)png_get_progressive_ptr(png_ptr);
if(png->pos + length > png->size) png_error(png_ptr, "Read Error");
memcpy(data, &png->data[png->pos], length);
png->pos += length;
}
unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
{
png_structp png_ptr;
png_infop info_ptr;
png_infop end_info;
unsigned char* pic;
unsigned char* row;
unsigned int x, y, c;
if(png_sig_cmp(png->data, 0, 8) != 0)
return NULL;
png->pos = 8;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
// (png_voidp)user_error_ptr, user_error_fn, user_warning_fn);
if(!png_ptr)
return NULL;
png_set_read_fn(png_ptr, (png_voidp)png, read_data_fn);
info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr)
{
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
return NULL;
}
end_info = png_create_info_struct(png_ptr);
if(!end_info)
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return NULL;
}
if(setjmp(png_jmpbuf(png_ptr)))
{
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
png_set_sig_bytes(png_ptr, 8);
png_read_png(
png_ptr, info_ptr,
PNG_TRANSFORM_STRIP_16 |
PNG_TRANSFORM_STRIP_ALPHA |
PNG_TRANSFORM_PACKING |
PNG_TRANSFORM_EXPAND |
PNG_TRANSFORM_BGR,
NULL);
if(png_get_channels(png_ptr, info_ptr) != 3)
{
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
pic = calloc(info_ptr->width * info_ptr->height, 4);
*w = info_ptr->width;
*h = info_ptr->height;
for(y = 0; y < info_ptr->height; y++)
{
row = &pic[y * info_ptr->width * 4];
for(x = 0; x < info_ptr->width*3; row += 4)
{
for(c = 0; c < 3; c++)
{
row[c] = info_ptr->row_pointers[y][x++];
}
}
}
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return pic;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
暴风影音VC++源码 (800个子文件)
all-wcprops 26KB
all-wcprops 6KB
all-wcprops 3KB
all-wcprops 2KB
ani.avi 15KB
authhdrpic.bmp 56KB
streamtypes.bmp 7KB
toolbar1.bmp 2KB
stereo.bmp 2KB
noaudio.bmp 2KB
mono.bmp 2KB
onoff.bmp 358B
libpng.c 3KB
MainFrm.cpp 254KB
mplayerc.cpp 83KB
DX9AllocatorPresenter.cpp 63KB
FGManager.cpp 57KB
PlayerCaptureDialog.cpp 44KB
DX7AllocatorPresenter.cpp 37KB
PlayerPlaylistBar.cpp 36KB
PlayerSubresyncBar.cpp 35KB
ConvertDlg.cpp 33KB
PPageAccelTbl.cpp 33KB
LineNumberEdit.cpp 29KB
PlayerListCtrl.cpp 21KB
PPageFormats.cpp 21KB
FakeFilterMapper2.cpp 20KB
RealMediaGraph.cpp 20KB
PPageExternalFilters.cpp 19KB
WebServer.cpp 18KB
WebClientSocket.cpp 18KB
RealMediaWindowlessSite.cpp 18KB
IPinHook.cpp 17KB
OpenCapDeviceDlg.cpp 17KB
QuicktimeGraph.cpp 16KB
BaseGraph.cpp 16KB
FGFilter.cpp 15KB
ShaderAutoCompleteDlg.cpp 13KB
ShaderEditorDlg.cpp 11KB
PPageAudioSwitcher.cpp 11KB
MediaFormats.cpp 10KB
jpeg.cpp 8KB
PPageDVD.cpp 8KB
PPageInternalFilters.cpp 8KB
PPageSubStyle.cpp 8KB
PlayerStatusBar.cpp 8KB
FavoriteOrganizeDlg.cpp 7KB
PPageFileInfoDetails.cpp 7KB
ChildView.cpp 7KB
TextPassThruFilter.cpp 7KB
PlayerSeekBar.cpp 7KB
PPageWebServer.cpp 6KB
ShockwaveGraph.cpp 6KB
PlayerToolBar.cpp 6KB
PnSPresetsDlg.cpp 6KB
SaveDlg.cpp 6KB
ComPropertySheet.cpp 6KB
PPageOutput.cpp 6KB
PPagePlayback.cpp 6KB
Playlist.cpp 6KB
PPagePlayer.cpp 6KB
StaticLink.cpp 6KB
OpenDlg.cpp 5KB
ConvertPropsDlg.cpp 5KB
PlayerInfoBar.cpp 5KB
GoToDlg.cpp 5KB
PPageLogo.cpp 5KB
VolumeCtrl.cpp 5KB
OpenFileDlg.cpp 5KB
RegFilterChooserDlg.cpp 4KB
MediaTypesDlg.cpp 4KB
PPageFileInfoRes.cpp 4KB
PPageSubtitles.cpp 4KB
DeinterlacerFilter.cpp 4KB
PPageTweaks.cpp 4KB
AuthDlg.cpp 4KB
SubtitleDlDlg.cpp 4KB
PPageFileInfoClip.cpp 3KB
FloatEdit.cpp 3KB
ConvertResDlg.cpp 3KB
ShaderCombineDlg.cpp 3KB
PixelShaderCompiler.cpp 3KB
PPageSubDB.cpp 3KB
PPageSheet.cpp 3KB
SaveTextFileDialog.cpp 3KB
MacrovisionKicker.cpp 3KB
StatusLabel.cpp 3KB
SelectMediaType.cpp 3KB
ComPropertyPage.cpp 3KB
SaveThumbnailsDialog.cpp 3KB
PPageBase.cpp 3KB
FileDropTarget.cpp 2KB
ConvertChapDlg.cpp 2KB
FavoriteAddDlg.cpp 2KB
PlayerShaderEditorBar.cpp 2KB
PPageFileInfoSheet.cpp 2KB
PlayerCaptureBar.cpp 2KB
ISDb.cpp 2KB
KeyProvider.cpp 2KB
CShockwaveFlash.cpp 1KB
共 800 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
tobywuxp
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功