I want to generate the colorful QR code.
I had used https://github.com/kuapay/iOS-QR-Code-Generator code to generate the QR code.
now the qr code generated is always n black color.I want to make it in Red or any
other color.
The coding of coloring And the drawing of QR code .png image is done QR_Draw_png.mm file.
What should i edit in QR_Draw_png.mm this file.
How to do the generate the colorful qr code.
How is it possible.
Please help me.
You'll have to tinker with the Z-Bar code to do that.
Maybe these links might help:
http://mashable.com/2011/04/18/qr-code-design-tips/
http://qreateandtrack.com/2011/01/06/adding-a-bit-of-color-to-your-qr-codes/
and
http://keremerkan.net/qr-code-and-2d-code-generator/
This is the best example to generate colorful QR code.
http://www.oscarsanderson.com/2013/08/12/implementing-a-qr-code-generator-on-the-iphone/
You will found qrencode library from above link, and Category of UIImage.
After you need to simple call this method with your selected Color to generate it.
mgView.image = [UIImage QRCodeGenerator:txtCouponName.text
andLightColour:[UIColor whiteColor]
andDarkColour:[UIColor blackColor]
andQuietZone:1
andSize:300];
https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=https://stackoverflow.com/questions/8063575/generate-colorful-qr-code%2F&choe=UTF-8
Use this link same generate web,android,iPhone.
QRCodeWriter writer = new QRCodeWriter();
try {
BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, 512, 512);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
// set colors for QR code
bmp.setPixel(x, y, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE);
}
}
((ImageView) findViewById(R.id.img_result_qr)).setImageBitmap(bmp);
} catch (WriterException e) {
e.printStackTrace();
}
Related
I have been trying to change the format from a camera that give a texture in Alpha8 to RGBA and have been unsuccessful so far.
This is the code I've tried:
public static class TextureHelperClass
{
public static Texture2D ChangeFormat(this Texture2D oldTexture, TextureFormat newFormat)
{
//Create new empty Texture
Texture2D newTex = new Texture2D(2, 2, newFormat, false);
//Copy old texture pixels into new one
newTex.SetPixels(oldTexture.GetPixels());
//Apply
newTex.Apply();
return newTex;
}
}
And I'm calling the code like this:
Texture imgTexture = Aplpha8Texture.ChangeFormat(TextureFormat.RGBA32);
But the image gets corrupted and isn't visible.
Does anyone know how to change this Alpha8 to RGBA so I can process it like any other image in OpenCV?
A friend provided me with the answer:
Color[] cs =oldTexture.GetPixels();
for(int i = 0; i < cs.Length; i++){//we want to set the r g b values to a
cs[i].r = cs[i].a;
cs[i].g = cs[i].a;
cs[i].b = cs[i].a;
cs[i].a = 1.0f;
}
//set the pixels in the new texture
newTex.SetPixels(cs);
//Apply
newTex.Apply();
This will take alot of resources but it will work for sure.
If you know a better way to make this change please add an answer to this thread.
As you can see in the picture, "Layout0" is selected with dark blue color.
I want to make this box too in my custom editor, but what I actually found is that this is not EditorGUILayout.BeginScrollView and other whatever stuffs.
could someone please tell me the keyword of this selectable box?
I am not entirely sure how the highlighting works but here's how I think it's implemented.
Make a scrollable view using GUILayout.BeginScrollView
Make a vertical view, but with help box style GUILayout.BeginVertical(EditorStyles.helpBox)
For the highlighting, create a blue texture and assign it to a GUIStyle, which you then use for the button. Do this on Awake so you only do this once.
Texture2D texture = new Texture2D(1, 1);
for(int x = 0; x < 1; x++)
{
for(int y = 0; y < 1; y++)
{
texture.SetPixel(x, y, Color.blue);
}
}
texture.Apply();
this.selectedStyle = new GUIStyle();
this.selectedStyle.normal.textColor = Color.white;
this.selectedStyle.normal.background = texture;
Change the buttons to label buttons GUILayout.Button("name", currentSelected ? this.selectedStyle : GUIStyle.label)
I am using mupdf to sign a pdf.
And I succeed to sign a annotation in pdf with function "pdf_update_ink_appearance"
Now I'm trying to insert an image into pdf.
I add below codes to insert image:
image = fz_new_image_from_file(ctx, "/storage/emulated/0/a.jpg");
fz_fill_image(ctx, dev, image, &page_ctm, 1.0f);
And the image doesn't show up in pdf.
I try another method, but the image also can't show up in pdf.
How to add a transparent image to PDF with mupdf using SMask?
Can anyone help this situation?
Thanks.
I am one of PyMuPDF's authors (a Python binding for MuPDF) and solved this exact task. You might have a look at the source code in GitHub.
The basic process is:
Create an image and then a pixmap from the file. If this pixmap has alpha (i.e. transparency), create another pixmap containg the alpha bytes and link like follows. After this add the main pixmap to the PDF. Finally Add an XObject referencing it to the page's /Resources, and invoke the XObject with a "Do" operator in the page's /Contents object.
if (filename)
{
image = fz_new_image_from_file(gctx, filename);
pix = fz_get_pixmap_from_image(gctx, image, NULL, NULL, 0, 0);
if (pix->alpha == 1)
{
j = pix->n - 1;
pm = fz_new_pixmap(gctx, NULL, pix->w, pix->h, seps, 0);
s = pix->samples;
t = pm->samples;
for (i = 0; i < pix->w * pix->h; i++)
t[i] = s[j + i * pix->n];
mask = fz_new_image_from_pixmap(gctx, pm, NULL);
zimg = fz_new_image_from_pixmap(gctx, pix, mask);
fz_drop_image(gctx, image);
image = zimg;
zimg = NULL;
}
}
Do have a look at file fitz.i and search for function insertImage. It's an SWIG interface file, but that part is plain C interfacing with MuPDF.
I'm capturing images from camera, and I have two function for saving 16-bit(!) image one in PNG and one in TIFF formats.
Could you please explain why the PNG is a very noisy image? like this:
PNG function:
bool save_image_png(const char *file_name,const mono16bit& img)
{
[...]
/* write header */
if (setjmp(png_jmpbuf(png_ptr)))
abort_("[write_png_file] Error during writing header");
png_set_IHDR(png_ptr, info_ptr, width, height,
bit_depth,PNG_COLOR_TYPE_GRAY , PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png_ptr, info_ptr);
/* write bytes */
if (setjmp(png_jmpbuf(png_ptr)))
abort_("[write_png_file] Error during writing bytes");
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
for (y=0; y<height; y++)
row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
for (y = 0; y < height; y++)
{
row_pointers[y] = (png_bytep)img.getBuffer() + y * width*2;
}
png_write_image(png_ptr, row_pointers);
/* end write */
[...]
}
and TIFF function:
bool save_image(const char *fname,const mono16bit& img)
{
[...]
for(y=0; y<height; y++) {
if((err=TIFFWriteScanline(tif,(tdata_t)(img.getBuffer()+width*y),y,0))==-1)
break;
}
TIFFClose(tif);
if(err==-1) {
fprintf(stderr,"Error writing to %s file\n",fname);
return false;
}
return true;
//#endif //USE_LIBTIFF
}
Thank you!
png_set_swap does nothing. You have to actually flip bytes in each pixel of the image.
If you’re on a PC and have SSSE3 or newer, a good way is _mm_shuffle_epi8 instruction, make a permute vector with _mm_setr_epi8.
If you’re on ARM and have NEON, use vrev16q_u8 instruction instead.
Perhaps you have a byte-order problem.
Try adding:
png_set_swap(png_ptr);
before saving the image
How does the cpSpaceShapeQuery function work? I can not find any doc about it.
Andrea
Yeah... I never got around to documenting that... Sorry. Basically you create a body and shape (neither needs to be added to the space) and use that to query much like the other query functions.
This code snippet makes a copy of a body and shape on the stack and then simulates it out to it's first predicted collision point drawing the path as it goes.
cpBody body = *(originalBody);
cpPolyShape shape = *((cpPolyShape *)originalShape);
shape.shape.body = &body;
cpFloat dt = 1.0f/60.0f;
cpVect gravity = space->gravity;
int count = 0;
for(int i=0; i<300; i++){
cpBodyUpdatePosition(&body, dt);
cpBodyUpdateVelocity(&body, gravity, 1.0f, dt);
if(cpSpaceShapeQuery(space, (cpShape *)&shape, NULL, NULL)){
quads[count%maxQuads] = quad(body.p, body.rot, CGRectMake(0, 2*32, 64, 64), tsize);
count++;
break;
}
if(i%10==0){
quads[count%maxQuads] = quad(body.p, body.rot, rect, tsize);
count++;
}
}