注意:我不是VB6程序员-我是负责生产中使用的应用程序的Android程序员,并且我的同事负责与我的Android设备对话的VB6程序。
过去,我们的VB6程序将Microsoft .bmps发送到Android设备,但是现在我们将平板电脑添加到我们的产品列表中,并且想要发送更大的图像以利用平板电脑的额外房地产,我们发现.bmp是太大而阻塞了网络。
Eventually we're replacing the old VB6 product with a .Net one, but until we do is there any way for VB6 to programmatically convert a bitmap to a JPEG? My colleague is unaware of one but I've always found S.O. to be very useful in my domains (Android, .Net) so I thought I'd try a VB6 question here.
我正在尝试将用户的整个桌面捕获为图像.我通过以下方式执行此操作:
public Bitmap CaptureScreen()
{
// Set up a bitmap of the correct size
Bitmap CapturedImage = new Bitmap((int)SystemInformation.VirtualScreen.Width,
(int)SystemInformation.VirtualScreen.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Create a graphics object from it
System.Drawing.Size size = new System.Drawing.Size((int)SystemInformation.VirtualScreen.Width, (int)SystemInformation.VirtualScreen.Height);
using (Graphics g = Graphics.FromImage(CapturedImage))
{
// copy the entire screen to the bitmap
g.CopyFromScreen(0, 0, 0, 0,
size, CopyPixelOperation.SourceCopy);
}
return CapturedImage;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试将PixelFormatfrom 更改Format32bppArgb为Format16bppArgb1555,则会产生一个OutOfMemoryException我不太懂的,考虑到我降低了质量.
有任何想法吗?或者我如何降低此图像的质量(因为它将以非常频繁的间隔通过网络发送)
我的下面的代码点击打开相机,拍照,从相机获取照片,然后进入imageview.但是我想拍摄图像并在图像上应用文本(某种时间戳,最好是图像中的时间戳,或者只是系统日期时间)并保存为jpeg.
如果有人能帮助我,那将是非常棒的.
public class PhotoIntentActivity extends Activity {
private static final int ACTION_TAKE_PHOTO_B = 1;
private static final String BITMAP_STORAGE_KEY = "viewbitmap";
private static final String IMAGEVIEW_VISIBILITY_STORAGE_KEY = "imageviewvisibility";
private ImageView mImageView;
private Bitmap mImageBitmap;
private String mCurrentPhotoPath;
private static final String JPEG_FILE_PREFIX = "IMG_";
private static final String JPEG_FILE_SUFFIX = ".jpg";
private AlbumStorageDirFactory mAlbumStorageDirFactory = null;
/* Photo album for this application */
private String getAlbumName() {
return getString(R.string.album_name);
}
private File getAlbumDir() {
File storageDir = null;
if …Run Code Online (Sandbox Code Playgroud) 我是新手,所以请跟我一起软=)
我正在尝试在LISP中开发一个脚本(抱歉,没有其他语言)来创建位图文件.我在不同的网站上关于位图格式,但我关心的是程序本身.
使用LISP,(和perl/awk,我的环境是Linux RHEL5)我只能创建一个带有"常规"ASCII码的文本文件(我的意思是可打印/可显示).
我的问题是关于不可打印的字符.例如,如果我想在十六进制链00 00 00 00中放入位图头,那么相应的ASCII代码是什么?
我怎么能在文件中打印它们?
非常感谢您的帮助和澄清!
最好,
P-CHAN
我想解码从base64到webmap的webservice中的图像,并在我的Android应用程序中使用它.这是我的方法:
public Bitmap getCaptcha() throws IOException
{
List<NameValuePair> params = new ArrayList<NameValuePair>();
String json = jsonParser.getCaptcha(captchaURL, params);
Log.i("", json);
byte [] encodeByte=Base64.decode(json.getBytes(),Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
return bitmap;
}
Run Code Online (Sandbox Code Playgroud)
如果我使用我的php脚本解码我从getCaptcha方法获得的字符串 - 它会正确显示.但是当我在我的应用程序中执行此操作时,我得到了一个
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assignmentexpert/com.assignmentexpert.RegisterActivity}: java.lang.IllegalArgumentException: bad base-64
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: bad base-64
at android.util.Base64.decode(Base64.java:161)
at android.util.Base64.decode(Base64.java:136)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写应用程序以从图库中获取图像,然后在其上执行一些效果,并在显示图像后,我想将其保存为SdCard中的JPG.任何人都可以告诉我如何在SD卡上保存图像,我应该在哪里放保存代码?这是我想要保存的地方,点击button2后:
public void onClick(View arg0) {
Bitmap yourimage;
yourimage=toGrayscale(yourSelectedImage);
ImageButton effected=(ImageButton)findViewById(R.id.imageButton2);
int width = 150;
int height =150;
Bitmap resizedbitmap=Bitmap.createScaledBitmap(yourimage, width, height, true);
effected.setImageBitmap(resizedbitmap);
}
Run Code Online (Sandbox Code Playgroud)
我的意思是在设置图像为resizedbitmap后,我想将其保存在SD卡中
我认为标题非常具有说明性,但这里有更详细的内容,我正在尝试做什么.基本上说我在内存中加载了BITMAP.
我想从中提取BITMAPINFOHEADER并将其添加到我的数据包结构中,该结构将通过套接字传输.*
转移它不是问题,但一旦它到达我想把它变回BITMAP,以便我可以使用它.
我一直在努力解决这个问题,而且我一直在搜索高低,没有任何运气.我需要完成此示例和函数列表会很有帮助.
非常感谢.我需要在win32 c ++中使用它.[没有.NET或MFC]赞赏.
根据文件Bitmap createBitmap (Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)方法:
从源位图的子集返回不可变位图,由可选矩阵转换.新位图可以是与源相同的对象,也可以是副本.它使用与原始位图相同的密度进行初始化.如果源位图是不可变的并且请求的子集与源位图本身相同,则返回源位图并且不创建新的位图.
我有一个方法,将方向应用于现有的位图:
private Bitmap getOrientedPhoto(Bitmap bitmap, int orientation) {
int rotate = 0;
switch (orientation) {
case ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ORIENTATION_ROTATE_90:
rotate = 90;
break;
default:
return bitmap;
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix mtx = new Matrix();
mtx.postRotate(rotate);
return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}
Run Code Online (Sandbox Code Playgroud)
我是从这里打电话的: …
我已经在很长一段时间里一直在努力解决这个问题.我想从资源文件夹中获取一个图像并编写一些文本,作为一个过程的一部分动态生成,然后将最终图像与文本保存在SD卡中.我知道如何在SD卡中写入文件.我无法在图像上写下文字.
我创建了一个带有imageview和textview的RelativeLayout并将其保存到SD卡但后来意识到我不必绘制视图.所以,不能用这个.
同样,我想强调一点,即我的应用程序不需要在当前屏幕上绘制位图.
有人可以提供任何解决方案吗?
谢谢!:)
我只有一个简单的问题.如何在按钮上设置位图?我用的方法
.setBackgroundResource(int resid)
Run Code Online (Sandbox Code Playgroud)
当我有可绘制的资源.但是我能为位图做些什么呢?