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

📄 rgbformattest.java

📁 FMJ(freedom media for java)是java视频开发的新选择
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
											{												final RGBFormat f1 = new RGBFormat(null, length,														 dataType, frameRate, bitsPerPixel, redMask, greenMask, blueMask);																																					assertEquals(f2.getBitsPerPixel(), f1.getBitsPerPixel());												assertEquals(f2.getEncoding(), f1.getEncoding());												assertEquals(f2.getBlueMask(), f1.getBlueMask());												assertEquals(f2.getDataType(), f1.getDataType());												assertEquals(f2.getFrameRate(), f1.getFrameRate());												assertEquals(f2.getGreenMask(), f1.getGreenMask());												assertEquals(f2.getMaxDataLength(), f1.getMaxDataLength());												assertEquals(f2.getRedMask(), f1.getRedMask());												//assertEquals(f2.getSize(), f1.getSize());																								assertEquals(f2.getEndian(), f1.getEndian());												assertEquals(f2.getFlipped(), f1.getFlipped());												//assertEquals(f2.getLineStride(), f1.getLineStride());												assertEquals(f2.getPixelStride(), f1.getPixelStride());											}																						// see if dataType affects - affects pixel stride, endian, line stride											{												final RGBFormat f1 = new RGBFormat(size, length,														 null, frameRate, bitsPerPixel, redMask, greenMask, blueMask);																																					assertEquals(f2.getBitsPerPixel(), f1.getBitsPerPixel());												assertEquals(f2.getEncoding(), f1.getEncoding());												assertEquals(f2.getBlueMask(), f1.getBlueMask());												//assertEquals(f2.getDataType(), f1.getDataType());												assertEquals(f2.getFrameRate(), f1.getFrameRate());												assertEquals(f2.getGreenMask(), f1.getGreenMask());												assertEquals(f2.getMaxDataLength(), f1.getMaxDataLength());												assertEquals(f2.getRedMask(), f1.getRedMask());												assertEquals(f2.getSize(), f1.getSize());																								//assertEquals(f2.getEndian(), f1.getEndian());												assertEquals(f2.getFlipped(), f1.getFlipped());												//assertEquals(f2.getLineStride(), f1.getLineStride());												//assertEquals(f2.getPixelStride(), f1.getPixelStride());											}																						// see if frameRate affects - DOES NOT.											{												final RGBFormat f1 = new RGBFormat(size, length,														 dataType, -1.f, bitsPerPixel, redMask, greenMask, blueMask);																																					assertEquals(f2.getBitsPerPixel(), f1.getBitsPerPixel());												assertEquals(f2.getEncoding(), f1.getEncoding());												assertEquals(f2.getBlueMask(), f1.getBlueMask());												assertEquals(f2.getDataType(), f1.getDataType());												//assertEquals(f2.getFrameRate(), f1.getFrameRate());												assertEquals(f2.getGreenMask(), f1.getGreenMask());												assertEquals(f2.getMaxDataLength(), f1.getMaxDataLength());												assertEquals(f2.getRedMask(), f1.getRedMask());												assertEquals(f2.getSize(), f1.getSize());																										assertEquals(f2.getEndian(), f1.getEndian());												assertEquals(f2.getFlipped(), f1.getFlipped());												assertEquals(f2.getLineStride(), f1.getLineStride());												assertEquals(f2.getPixelStride(), f1.getPixelStride());											}																						// see if bitsPerPixel affects - affects pixel stride, endian, line stride											{												final RGBFormat f1 = new RGBFormat(size, length,														 dataType, frameRate, -1, redMask, greenMask, blueMask);																																					//assertEquals(f2.getBitsPerPixel(), f1.getBitsPerPixel());												assertEquals(f2.getEncoding(), f1.getEncoding());												assertEquals(f2.getBlueMask(), f1.getBlueMask());												assertEquals(f2.getDataType(), f1.getDataType());												assertEquals(f2.getFrameRate(), f1.getFrameRate());												assertEquals(f2.getGreenMask(), f1.getGreenMask());												assertEquals(f2.getMaxDataLength(), f1.getMaxDataLength());												assertEquals(f2.getRedMask(), f1.getRedMask());												assertEquals(f2.getSize(), f1.getSize());																								//assertEquals(f2.getEndian(), f1.getEndian());												assertEquals(f2.getFlipped(), f1.getFlipped());												//assertEquals(f2.getLineStride(), f1.getLineStride());												//assertEquals(f2.getPixelStride(), f1.getPixelStride());																																															}																						testHypothesis(f2);																							}									}								}							}													}					}				}			}						// summary:			// see if size affects - affects line stride			// see if dataType affects - affects pixel stride, endian, line stride//			 see if bitsPerPixel affects - affects pixel stride, endian, line stride						// so, in reverse, line stride is affected by size, dataType, and bitsPerPixel			// pixelStride is affected by dataType and bitsPerPixel			// endian  is affected by dataType and bitsPerPixel			//			// dump out some csv to analyze in openoffice - first line stride//			if (false)//			{//				System.out.println();//				System.out.println("sizex,sizey,datatype,bpp,linestride");//				for (int length : new int[] {-1})//				{//					for (int redMask : new int[] {-1})//					{//						for (int greenMask : new int[] {-1})//						{//							for (int blueMask : new int[] {-1})//							{//								for (Dimension size : sizes)//								{//									for (Class dataType : dataTypes)//									{//										for (float frameRate : new float[] {-1.f})//										{//											for (int bitsPerPixel : bitsPerPixels)//											{//												final RGBFormat f2 = new RGBFormat(size, length,//														 dataType, frameRate, bitsPerPixel, redMask, greenMask, blueMask);//													//													System.out.print(f2.getSize() == null ? "\"null\"": ("" + f2.getSize().width));//													System.out.print(",");//													System.out.print(f2.getSize() == null ? "\"null\"": ("" + f2.getSize().height));//													System.out.print(",");//													System.out.print("\"" + f2.getDataType() + "\"");//													System.out.print(",");//													System.out.print(f2.getBitsPerPixel());//													System.out.print(",");//													System.out.print("" + f2.getLineStride());//													System.out.println();//													//											}//										}//									}//								}//								//							}//						}//					}//				}//			}//			//			// pixel stride//			if (false)//			{//				System.out.println();//				System.out.println("datatype,bpp,pixelstride");//				for (int length : new int[] {-1})//				{//					for (int redMask : new int[] {-1})//					{//						for (int greenMask : new int[] {-1})//						{//							for (int blueMask : new int[] {-1})//							{//								for (Dimension size : new Dimension[] {null})//								{//									for (Class dataType : dataTypes)//									{//										for (float frameRate : new float[] {-1.f})//										{//											for (int bitsPerPixel : bitsPerPixels)//											{//												final RGBFormat f2 = new RGBFormat(size, length,//														 dataType, frameRate, bitsPerPixel, redMask, greenMask, blueMask);//													//													System.out.print("\"" + f2.getDataType() + "\"");//													System.out.print(",");//													System.out.print(f2.getBitsPerPixel());//													System.out.print(",");//													System.out.print("" + f2.getPixelStride());//													System.out.println();//													//											}//										}//									}//								}//								//							}//						}//					}//				}//			}//			//			//			// endian//			if (false)//			{//				System.out.println();//				System.out.println("datatype,bpp,endian");//				for (int length : new int[] {-1})//				{//					for (int redMask : new int[] {-1})//					{//						for (int greenMask : new int[] {-1})//						{//							for (int blueMask : new int[] {-1})//							{//								for (Dimension size : new Dimension[] {null})//								{//									for (Class dataType : dataTypes)//									{//										for (float frameRate : new float[] {-1.f})//										{//											for (int bitsPerPixel : bitsPerPixels)//											{//												final RGBFormat f2 = new RGBFormat(size, length,//														 dataType, frameRate, bitsPerPixel, redMask, greenMask, blueMask);//													//													System.out.print("\"" + f2.getDataType() + "\"");//													System.out.print(",");//													System.out.print(f2.getBitsPerPixel());//													System.out.print(",");//													System.out.print("" + f2.getEndian());//													System.out.println();//													//											}//										}//									}//								}//								//							}//						}//					}//				}//			}					}							}		// hypothesis from analysing the csv output:	void testHypothesis(RGBFormat f2)	{		// pixel stride:		if (f2.getDataType() == null || f2.getBitsPerPixel() == -1)			assertEquals(f2.getPixelStride(), -1);		else if (f2.getDataType() == byte[].class)		{	if (f2.getBitsPerPixel() < 8)				assertEquals(f2.getPixelStride(), 0);			else if (f2.getBitsPerPixel() < 16)				assertEquals(f2.getPixelStride(), 1);			else if (f2.getBitsPerPixel() < 24)				assertEquals(f2.getPixelStride(), 2);			else if (f2.getBitsPerPixel() < 32)				assertEquals(f2.getPixelStride(), 3);			else				assertEquals(f2.getPixelStride(), 4);	// TODO: what about higher values.  looks like div by 8, truncate					assertEquals(f2.getPixelStride(), f2.getBitsPerPixel() / 8);		}		else		{	// short, and int arrays			assertEquals(f2.getPixelStride(), 1);		}				// endian				if (f2.getDataType() == byte[].class && f2.getBitsPerPixel() == 16)		{	assertEquals(f2.getEndian(), 1);		}		else		{	assertEquals(f2.getEndian(), -1);		}				// line stride:		if (f2.getDataType() == null || f2.getSize() == null || f2.getBitsPerPixel() == -1)		{			assertEquals(f2.getLineStride(), -1);		}		else		{			if (f2.getDataType() == byte[].class)			{				assertEquals(f2.getLineStride(), f2.getSize().width  * (f2.getBitsPerPixel() / 8));			}			else			{				assertEquals(f2.getLineStride(), f2.getSize().width);			}		}			}		public void testClone()	{		assertEquals(new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).clone(),				 new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1));					}		public void testMatches()	{		assertFalse(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1)));		assertTrue(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1)				.matches( new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)						));		assertFalse(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1).matches(				 new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1)));		assertTrue(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)));		assertFalse(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1)));		assertTrue(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)));		assertTrue( new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1)));		assertFalse(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1)));		assertTrue(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)));		assertTrue(new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1).matches(				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1)));									}	public void testIntersects()	{		assertEquals(				 new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1)				 .intersects(				 new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1) ), 				 new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1));				assertEquals(				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, -1, -1, -1, -1).intersects(				new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)),				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1));		assertEquals(				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1),				new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1));	}			private void assertEquals(double a, double b)	{		assertTrue(a == b);	}	}

⌨️ 快捷键说明

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