¾È±Ô °øºÎ¹æ

Android > Bitmap , BitmapFactory - Á¤¸®

µî·ÏÀÏ : 2017-07-06 17:52 Á¶È¸¼ö : 53,141

Bitmap Àº ¸Ó¾ß?

¾Èµå·ÎÀ̵忡¼­ À̹ÌÁö¸¦ Ç¥ÇöÇϱâ À§ÇØ »ç¿ëµÇ´Â ³à¼®ÀÌ BitmapÀÔ´Ï´Ù.

Bitmap¿Í °°ÀÌ ºÁ¾ßµÉ ³à¼®Àº BtimapFactoryŬ·¡½º Àε¥ À̸§¿¡¼­ ¾Ë¼ö ÀÖµíÀÌ "Factory" °øÀåÀÔ´Ï´Ù.

¹Ù·Î Bitmap¸¦ ¸¸µé¾î ÁÖ´Â ³à¼®ÀÌÁÒ. ¾Èµå·ÎÀ̵忡¼­ »ç¿ëÀÚ°¡ ¿øÇÏ´Â À̹ÌÁö¸¦ ÄÚµå»ó¿¡ ³ÖÀ»·Á¸é ÇØ´ç À̹ÌÁö´Â

/res/drawable-xxxx/ °÷¿¡ ³ÖÀ¸½Ã¸é µË´Ï´Ù. ±ÇÀåÇÏ´Â È®ÀåÀÚ´Â pngÀÌÁö¸¸ jpgµµµË´Ï´Ù.

ÆÄÀÏÀ» ³ÖÀ¸½Ç¶§ ÁÖÀÇ ÇÏ¼Å¾ß µÉ°ÍÀº ÆÄÀÏÀ̸§Àº ¿µ¾î¼Ò¹®ÀÚ, _(¾ð´õ¹Ù) ¸¸ »ç¿ë°¡´ÉÇϴٴ°ŠÀØÁö¸¶¼¼¿ä.
1. BitmapFactory - Method

BitmapÀ» ´Ù·ç±â À§ÇØ ÁÖ·Î »ç¿ëµÇ´Â ³à¼®Àº Bitmap¾È¿¡ ÀÖ´Â ¸Þ¼Òµå°¡ ¾Æ´Ï¶ó BitmapFactory¾È¿¡ ÀÖ´Â ¸Þ¼Òµå¸¦ ÁÖ·Î »ç¿ëÇÕ´Ï´Ù. 

¿Ö±×¸® µÇ³Ä¸é, À̹ÌÁö »ý¼º(°øÀå¿¡¼­ ¸¸µé±â : BitmapFactory ) ---> È­¸é¿¡ ±×¸®±â (Canvas¿¡ ±×¸®±â : Canvas )

À§ÀÇ ´Ü°è¸¸ °ÅÄ¡¸é µÇ´Ï °øÀå¿¡¼­ »ç¿ëµÇ´Â ¸Þ¼Òµå°¡ ÇÊ¿äÇÏ°ÚÁÒ?

BitmapFacroty ¸Þ¼Òµå - ¸ðµÎ public static Bitmap ·Î ½ÃÀÛÇÏ´Ï »ý·«Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù.
1-1. decodeByteArray
byte ¹è¿­ ÇüÅ·ΠµÇ¾îÀÖ´Â À̹ÌÁö¸¦ BitmapÀ¸·Î ¸¸µé¶§ »ç¿ëÇÕ´Ï´Ù.
 
		decodeByteArray(byte[] data, int offset, int length, BitmapFactory.Options opts)
		decodeByteArray(byte[] data, int offset, int length)


1-2. decodeFile(String pathName)
ÈÞ´ëÆù ¾È¿¡ ÆÄÀÏ ÇüÅ·ΠÀúÀåµÈ À̹ÌÁö¸¦ BitmapÀ¸·Î ¸¸µé¶§ »ç¿ëÇÕ´Ï´Ù.
 
		decodeFile(String pathName, BitmapFactory.Options opts)

		
		»ç¿ë¿¹)
		------------------------
		Bitmap _bit = BitmapFactory.decodeFile("/sdcard/aaa.jpg");


1-3. decodeFileDescriptor(FileDescriptor fd)

FileDescripter·ÎºÎÅÍ Bitmap¸¦ ¸¸µé¶§ »ç¿ëµË´Ï´Ù. (FileDescripter´Â java.io ÆÐÅ°Áö¸¦ »ìÆ캸½Ã¸é µË´Ï´Ù.)
 
decodeFileDescriptor(FileDescriptor fd, Rect outPadding, BitmapFactory.Options opts)


1-4. decodeFileDescriptor(FileDescriptor fd)

res Æú´õ¿¡ ÀúÀåµÈ ³à¼®µéÀ» BitmapÀ¸·Î ¸¸µé¶§ »ç¿ëÇÕ´Ï´Ù.
 
		decodeResource(Resources res, int id, BitmapFactory.Options opts)
		decodeResource(Resources res, int id)
		decodeResourceStream(Resources res, TypedValue value, InputStream is,Rect pad, BitmapFactory.Options opts)
		
		»ç¿ë¿¹)
		------------------------
		Bitmap _bit = BitmapFactory.decodeResource(getResources(), R.drawable.bbb);


1-5. decodeStream(InputStream is)

InputStreamÀ¸·Î ºÎÅÍ BitmapÀ» ¸¸µé¶§ »ç¿ëÇÕ´Ï´Ù.
 
decodeStream(InputStream is, Rect outPadding, BitmapFactory.Options opts)



±×¸®°í ÀÌ»óÇÑ ³à¼®ÀÌ ´õ³ª¿ÀÁÒ?  ¹Ù·Î BitmapFactory.Options À̶ó´Â Ŭ·¡½ºÀä.

À̳༮Àº BitmapFactoryÀÇ ³»ºÎŬ·¡½º·Î½á À̸§Ã³·³ ¿É¼Ç ¼³Á¤À» ÇÕ´Ï´Ù. 

¾à°£ ƯÀÌÇÑ°ÍÀÌ À̳༮Àº Bitmap¿¡ ´ëÇÑ ¿É¼ÇÀÌ´Ù º¸´Ï ¸Þ¼Òµåº¸´Ù´Â º¯¼ö¸¦ ÁÖ·Î »ç¿ëÇÕ´Ï´Ù. Çѹø »ìÆì º¸°Ú½À´Ï´Ù.

2. BitmapFactory.Options ¿¡¼­ »ç¿ëµÇ´Â º¯¼ö


public Bitmap     inBitmap
- ¼³Á¤ÇÏ¸é ºñÆ®¸Ê ·Îµù½Ã ¼³Á¤ÇÑ ºñÆ®¸ÊÀ» Àç»ç¿ëÇÕ´Ï´Ù.

public int   inDensity
- Çȼ¿ÀÇ ¹Ðµµ ´ÜÀ§¸¦ ºñÆ®¸Ê¿¡ »ç¿ëÇÕ´Ï´Ù.

public boolean         inDither
    - true·Î ¼³Á¤µÈ´Ù¸é ÇØ´çÀ̹ÌÁö¿¡ dither¸¦ Àû¿ëÇÕ´Ï´Ù.


public boolean   inInputShareable

public boolean   inJustDecodeBounds
public boolean   inMutable

- true·Î ¼³Á¤ÇÏ¸é ºÒº¯ÇÏ´Â À̹ÌÁö¸¦ ¸®ÅÏÇÕ´Ï´Ù.

public boolean    inPreferQualityOverSpeed
- true·Î ¼³Á¤ÇÏ¸é ¼Óµµº¸´Ù´Â °íÇ°ÁúÀ» ¼ö¼±À¸·Î ÇÏ¿© µðÄÚµù ÇÕ´Ï´Ù.

public Bitmap.Config        inPreferredConfig
- nullÀÌ ¾Æ´Ï¸é ³»ºÎ ¼³Á¤À¸·Î µðÄÚµùÇÕ´Ï´Ù.

public boolean inPurgeable
public int     inSampleSize
- ¸Þ¸ð¸®¸¦ Àý¾àÇϱâ À§Çؼ­ »ç¿ëµÇ¸ç 1ÀÌ»óÀÇ ¼ýÀÚ°ªÀÌ ¼³Á¤µÇ¸é ±×¼ýÀÚ¸¸Å­ Ãà¼Ò½ÃŲ´Ù.

public boolean   inScaled
public int   inScreenDensity
public int   inTargetDensity
public byte[] inTempStorage
public boolean    mCancel
- ÇØ´ç Object°¡ Ãë¼Ò µÇ¾úÀ»¶§´Â ³ªÅ¸³»´Â Ç÷¡±×°ª

public int    outHeight
- À̹ÌÁöÀÇ ³ôÀ̸¦ ¼³Á¤ÇÕ´Ï´Ù. ¸¸¾à µðÄÚµùÁß ¿¡·¯°¡ ¹ß»ýÇϸé -1·Î ¼³Á¤µË´Ï´Ù.

public String   outMimeType
- µðÄÚµùµÈ À̹ÌÁöÀÇ MIMEŸÀÔÀ» ¼³Á¤ÇÕ´Ï´Ù.

public int outWidth
- À̹ÌÁöÀÇ ÆøÀ» ¼³Á¤ÇÕ´Ï´Ù. ¸¸¾à µðÄÚµùÁß ¿¡·¯°¡ ¹ß»ýÇϸé -1·Î ¼³Á¤µË´Ï´Ù.




À§¸¦ º¸½Ã¸é ºñ¾îÀÖ´Â ³à¼®µéÀÌ ÀÖÁÒ?  ¿©·¯ºÐÀÇ µµ¿òÀÌ ÇÊ¿äÇÕ´Ï´Ù.

¾Æ½Ã´Â ºÐµéÀº ´ñ±ÛÀ» ´Þ¾Æ ÁÖ½Ã¸é ¼öÁ¤ÇØ ³õµµ·Ï ÇÏ°Ú½À´Ï´Ù.

Àú´Â ´Ù¸¥ ³à¼®µéÀº °ÅÀÇ ¾²Áö ¾Ê±¸¿ä.  ¸Þ¸ð¸® È¿À²¼ºÀ» À§ÇØ inSampleSize¸¦ °¡À帹ÀÌ »ç¿ëÇÑ´ä´Ï´Ù.


Bitmap ÀÌ¿ÜÀÇ Ãʺ¸ÇÃ¹Ö´Ô °­Á ÀÔ´Ï´Ù. °­ÀÇ°¡ Âü ÁÁ½À´Ï´Ù.~!!

 
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.